php-censor/PHPCI/Model/Project.php

62 lines
1.5 KiB
PHP
Raw Normal View History

2013-05-03 17:02:53 +02:00
<?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/
*/
2013-05-03 17:02:53 +02:00
namespace PHPCI\Model;
use PHPCI\Model\Base\ProjectBase;
use PHPCI\Model\Build;
use b8\Store;
2013-05-03 17:02:53 +02:00
/**
* Project Model
* @uses PHPCI\Model\Base\ProjectBase
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Core
*/
2013-05-03 17:02:53 +02:00
class Project extends ProjectBase
{
public function getLatestBuild($branch = 'master', $status = null)
{
$criteria = array('branch' => $branch, 'project_id' => $this->getId());
if (isset($status)) {
$criteria['status'] = $status;
}
$order = array('id' => 'DESC');
$builds = Store\Factory::getStore('Build')->getWhere($criteria, 1, 0, array(), $order);
if (is_array($builds['items']) && count($builds['items'])) {
$latest = array_shift($builds['items']);
if (isset($latest) && $latest instanceof Build) {
return $latest;
}
}
return null;
}
2014-02-26 16:23:24 +01:00
public function getAccessInformation($key = null)
{
$data = unserialize($this->data['access_information']);
if (is_null($key)) {
$rtn = $data;
} elseif (isset($data[$key])) {
$rtn = $data[$key];
} else {
$rtn = null;
}
return $rtn;
}
2013-05-03 17:02:53 +02:00
}