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

@ -15,25 +15,36 @@ class BuildErrorStore extends Store
/**
* Get a BuildError by primary key (Id)
*
* @param integer $key
* @param string $useConnection
*
* @return null|BuildError
*/
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 BuildError by Id.
*
* @param integer $id
* @param string $useConnection
*
* @return null|BuildError
*
* @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_error}} 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 BuildErrorStore extends Store
/**
* Get multiple BuildError 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_error}} 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()) {
@ -78,8 +96,10 @@ class BuildErrorStore extends Store
/**
* Get a list of errors for a given build, since a given time.
* @param $buildId
* @param string $since date string
*
* @param integer $buildId
* @param string $since date string
*
* @return array
*/
public function getErrorsForBuild($buildId, $since = null)
@ -116,8 +136,9 @@ class BuildErrorStore extends Store
/**
* Gets the total number of errors for a given build.
* @param $buildId
* @param string $since date string
*
* @param integer $buildId
*
* @return array
*/
public function getErrorTotalForBuild($buildId)