Code style fixes + phpdocs.

This commit is contained in:
Dmitry Khomutov 2017-10-15 01:29:29 +07:00
commit 508465fc74
8 changed files with 274 additions and 166 deletions

View file

@ -9,31 +9,42 @@ use b8\Exception\HttpException;
class BuildMetaStore extends Store
{
protected $tableName = 'build_meta';
protected $modelName = '\PHPCensor\Model\BuildMeta';
protected $primaryKey = 'id';
protected $tableName = 'build_meta';
protected $modelName = '\PHPCensor\Model\BuildMeta';
protected $primaryKey = 'id';
/**
* Get a BuildMeta by primary key (Id)
*
* @param integer $key
* @param string $useConnection
*
* @return null|BuildMeta
*/
public function getByPrimaryKey($value, $useConnection = 'read')
public function getByPrimaryKey($key, $useConnection = 'read')
{
return $this->getById($value, $useConnection);
return $this->getById($key, $useConnection);
}
/**
* Get a single BuildMeta by Id.
*
* @param integer $id
* @param string $useConnection
*
* @return null|BuildMeta
*
* @throws HttpException
*/
public function getById($value, $useConnection = 'read')
public function getById($id, $useConnection = 'read')
{
if (is_null($value)) {
if (is_null($id)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build_meta}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
$stmt->bindValue(':id', $id);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
@ -46,18 +57,25 @@ class BuildMetaStore extends Store
/**
* Get multiple BuildMeta by BuildId.
*
* @param integer $buildId
* @param integer $limit
* @param string $useConnection
*
* @return array
*
* @throws HttpException
*/
public function getByBuildId($value, $limit = 1000, $useConnection = 'read')
public function getByBuildId($buildId, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
if (is_null($buildId)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build_meta}} WHERE {{build_id}} = :build_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':build_id', $value);
$stmt->bindValue(':build_id', $buildId);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {