php-censor/src/PHPCensor/Store/BuildMetaStore.php

53 lines
1.3 KiB
PHP
Raw Normal View History

<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
2016-07-19 20:28:11 +02:00
namespace PHPCensor\Store;
2016-07-19 20:28:11 +02:00
use PHPCensor\Store\Base\BuildMetaStoreBase;
use b8\Database;
2016-07-19 20:28:11 +02:00
use PHPCensor\Model\BuildMeta;
/**
* BuildMeta Store
* @uses PHPCensor\Store\Base\BuildMetaStoreBase
*/
class BuildMetaStore extends BuildMetaStoreBase
{
2015-10-15 11:17:22 +02:00
/**
* Only used by an upgrade migration to move errors from build_meta to build_error
2016-05-09 08:20:26 +02:00
*
2015-10-15 11:17:22 +02:00
* @param $limit
2016-05-09 08:20:26 +02:00
*
2015-10-15 11:17:22 +02:00
* @return array
*/
2015-10-15 15:23:55 +02:00
public function getErrorsForUpgrade($limit)
{
$query = 'SELECT * FROM build_meta
2016-04-25 19:30:23 +02:00
WHERE meta_key IN (\'phpmd-data\', \'phpcs-data\', \'phpdoccheck-data\', \'technical_debt - data\')
2015-10-15 15:23:55 +02:00
ORDER BY id ASC LIMIT :limit';
$stmt = Database::getConnection('read')->prepare($query);
$stmt->bindValue(':limit', $limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new BuildMeta($item);
};
$rtn = array_map($map, $res);
return $rtn;
} else {
2016-04-21 06:58:09 +02:00
return [];
}
}
2013-10-10 02:12:30 +02:00
}