2013-10-08 08:21:46 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2014-05-12 18:26:17 +02:00
|
|
|
* 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/
|
2013-10-08 08:21:46 +02:00
|
|
|
*/
|
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
namespace PHPCensor\Store;
|
2013-10-08 08:21:46 +02:00
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
use PHPCensor\Store\Base\BuildMetaStoreBase;
|
2015-10-15 11:07:54 +02:00
|
|
|
use b8\Database;
|
2016-07-19 20:28:11 +02:00
|
|
|
use PHPCensor\Model\BuildMeta;
|
2013-10-08 08:21:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* BuildMeta Store
|
2016-07-21 19:20:59 +02:00
|
|
|
* @uses PHPCensor\Store\Base\BuildMetaStoreBase
|
2013-10-08 08:21:46 +02:00
|
|
|
*/
|
|
|
|
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)
|
2015-10-15 11:07:54 +02:00
|
|
|
{
|
|
|
|
$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';
|
2015-10-15 11:07:54 +02:00
|
|
|
|
|
|
|
$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 [];
|
2015-10-15 11:07:54 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-10 02:12:30 +02:00
|
|
|
}
|