From 11a3e3403f664fe9b9bc89e2a5c249f93a52f16a Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Thu, 16 May 2013 15:40:40 +0100 Subject: [PATCH] PHPCI/Helper and PHPCI/Model PSR2 compliance. Issue #18 --- PHPCI/Helper/User.php | 12 +- PHPCI/Model/Base/BuildBase.php | 1067 +++++++++++++------------- PHPCI/Model/Base/ProjectBase.php | 526 +++++++------ PHPCI/Model/Base/UserBase.php | 439 ++++++----- PHPCI/Model/Build.php | 38 +- PHPCI/Model/Build/BitbucketBuild.php | 40 +- PHPCI/Model/Build/GithubBuild.php | 107 ++- PHPCI/Model/Build/LocalBuild.php | 62 +- PHPCI/Model/Build/RemoteGitBuild.php | 89 +-- PHPCI/Model/Project.php | 4 +- PHPCI/Model/User.php | 6 +- PHPCI/Store/BuildStore.php | 8 +- 12 files changed, 1186 insertions(+), 1212 deletions(-) diff --git a/PHPCI/Helper/User.php b/PHPCI/Helper/User.php index aea39fbe..e421520c 100644 --- a/PHPCI/Helper/User.php +++ b/PHPCI/Helper/User.php @@ -17,9 +17,9 @@ namespace PHPCI\Helper; */ class User { - public function __call($method, $params = array()) - { - $user = \b8\Registry::getInstance()->get('user'); - return call_user_func_array(array($user, $method), $params); - } -} \ No newline at end of file + public function __call($method, $params = array()) + { + $user = \b8\Registry::getInstance()->get('user'); + return call_user_func_array(array($user, $method), $params); + } +} diff --git a/PHPCI/Model/Base/BuildBase.php b/PHPCI/Model/Base/BuildBase.php index 55b4182d..1a6d3549 100644 --- a/PHPCI/Model/Base/BuildBase.php +++ b/PHPCI/Model/Base/BuildBase.php @@ -5,6 +5,7 @@ */ namespace PHPCI\Model\Base; + use b8\Model; /** @@ -12,543 +13,531 @@ use b8\Model; */ class BuildBase extends Model { - /** - * @var array - */ - public static $sleepable = array(); - - /** - * @var string - */ - protected $_tableName = 'build'; - - /** - * @var string - */ - protected $_modelName = 'Build'; - - /** - * @var array - */ - protected $_data = array( - 'id' => null, - 'project_id' => null, - 'commit_id' => null, - 'status' => null, - 'log' => null, - 'branch' => null, - 'created' => null, - 'started' => null, - 'finished' => null, - 'plugins' => null, - ); - - /** - * @var array - */ - protected $_getters = array( - 'id' => 'getId', - 'project_id' => 'getProjectId', - 'commit_id' => 'getCommitId', - 'status' => 'getStatus', - 'log' => 'getLog', - 'branch' => 'getBranch', - 'created' => 'getCreated', - 'started' => 'getStarted', - 'finished' => 'getFinished', - 'plugins' => 'getPlugins', - 'Project' => 'getProject', - ); - - /** - * @var array - */ - protected $_setters = array( - 'id' => 'setId', - 'project_id' => 'setProjectId', - 'commit_id' => 'setCommitId', - 'status' => 'setStatus', - 'log' => 'setLog', - 'branch' => 'setBranch', - 'created' => 'setCreated', - 'started' => 'setStarted', - 'finished' => 'setFinished', - 'plugins' => 'setPlugins', - 'Project' => 'setProject', - ); - - /** - * @var array - */ - public $columns = array( - 'id' => array( - 'type' => 'int', - 'length' => '11', - 'primary_key' => true, - 'auto_increment' => true, - ), - 'project_id' => array( - 'type' => 'int', - 'length' => '11', - ), - 'commit_id' => array( - 'type' => 'varchar', - 'length' => '50', - ), - 'status' => array( - 'type' => 'tinyint', - 'length' => '4', - ), - 'log' => array( - 'type' => 'text', - 'length' => '', - 'nullable' => true, - ), - 'branch' => array( - 'type' => 'varchar', - 'length' => '50', - ), - 'created' => array( - 'type' => 'datetime', - 'length' => '', - 'nullable' => true, - ), - 'started' => array( - 'type' => 'datetime', - 'length' => '', - 'nullable' => true, - ), - 'finished' => array( - 'type' => 'datetime', - 'length' => '', - 'nullable' => true, - ), - 'plugins' => array( - 'type' => 'text', - 'length' => '', - 'nullable' => true, - ), - ); - - /** - * @var array - */ - public $indexes = array( - 'PRIMARY' => array('unique' => true, 'columns' => 'id'), - 'project_id' => array('columns' => 'project_id'), - 'idx_status' => array('columns' => 'status'), - ); - - /** - * @var array - */ - public $foreignKeys = array( - 'build_ibfk_1' => array('local_col' => 'project_id', 'update' => 'CASCADE', 'delete' => 'CASCADE', 'table' => 'project', 'col' => 'id'), - ); - - - /** - * Get the value of Id / id. - * - * @return int - */ - public function getId() - { - $rtn = $this->_data['id']; - - - return $rtn; - } - - /** - * Get the value of ProjectId / project_id. - * - * @return int - */ - public function getProjectId() - { - $rtn = $this->_data['project_id']; - - - return $rtn; - } - - /** - * Get the value of CommitId / commit_id. - * - * @return string - */ - public function getCommitId() - { - $rtn = $this->_data['commit_id']; - - - return $rtn; - } - - /** - * Get the value of Status / status. - * - * @return int - */ - public function getStatus() - { - $rtn = $this->_data['status']; - - - return $rtn; - } - - /** - * Get the value of Log / log. - * - * @return string - */ - public function getLog() - { - $rtn = $this->_data['log']; - - - return $rtn; - } - - /** - * Get the value of Branch / branch. - * - * @return string - */ - public function getBranch() - { - $rtn = $this->_data['branch']; - - - return $rtn; - } - - /** - * Get the value of Created / created. - * - * @return \DateTime - */ - public function getCreated() - { - $rtn = $this->_data['created']; - - - if(!empty($rtn)) - { - $rtn = new \DateTime($rtn); - } - - - return $rtn; - } - - /** - * Get the value of Started / started. - * - * @return \DateTime - */ - public function getStarted() - { - $rtn = $this->_data['started']; - - - if(!empty($rtn)) - { - $rtn = new \DateTime($rtn); - } - - - return $rtn; - } - - /** - * Get the value of Finished / finished. - * - * @return \DateTime - */ - public function getFinished() - { - $rtn = $this->_data['finished']; - - - if(!empty($rtn)) - { - $rtn = new \DateTime($rtn); - } - - - return $rtn; - } - - /** - * Get the value of Plugins / plugins. - * - * @return string - */ - public function getPlugins() - { - $rtn = $this->_data['plugins']; - - - return $rtn; - } - - /** - * Set the value of Id / id. - * - * Must not be null. - * @param $value int - */ - public function setId($value) - { - $this->_validateNotNull('Id', $value); - $this->_validateInt('Id', $value); - if($this->_data['id'] === $value) - { - return; - } - - $this->_data['id'] = $value; - - $this->_setModified('id'); - } - - /** - * Set the value of ProjectId / project_id. - * - * Must not be null. - * @param $value int - */ - public function setProjectId($value) - { - $this->_validateNotNull('ProjectId', $value); - $this->_validateInt('ProjectId', $value); - if($this->_data['project_id'] === $value) - { - return; - } - - $this->_data['project_id'] = $value; - - $this->_setModified('project_id'); - } - - /** - * Set the value of CommitId / commit_id. - * - * Must not be null. - * @param $value string - */ - public function setCommitId($value) - { - $this->_validateNotNull('CommitId', $value); - $this->_validateString('CommitId', $value); - if($this->_data['commit_id'] === $value) - { - return; - } - - $this->_data['commit_id'] = $value; - - $this->_setModified('commit_id'); - } - - /** - * Set the value of Status / status. - * - * Must not be null. - * @param $value int - */ - public function setStatus($value) - { - $this->_validateNotNull('Status', $value); - $this->_validateInt('Status', $value); - if($this->_data['status'] === $value) - { - return; - } - - $this->_data['status'] = $value; - - $this->_setModified('status'); - } - - /** - * Set the value of Log / log. - * - * @param $value string - */ - public function setLog($value) - { - - $this->_validateString('Log', $value); - if($this->_data['log'] === $value) - { - return; - } - - $this->_data['log'] = $value; - - $this->_setModified('log'); - } - - /** - * Set the value of Branch / branch. - * - * Must not be null. - * @param $value string - */ - public function setBranch($value) - { - $this->_validateNotNull('Branch', $value); - $this->_validateString('Branch', $value); - if($this->_data['branch'] === $value) - { - return; - } - - $this->_data['branch'] = $value; - - $this->_setModified('branch'); - } - - /** - * Set the value of Created / created. - * - * @param $value \DateTime - */ - public function setCreated($value) - { - - $this->_validateDate('Created', $value); - if($this->_data['created'] === $value) - { - return; - } - - $this->_data['created'] = $value; - - $this->_setModified('created'); - } - - /** - * Set the value of Started / started. - * - * @param $value \DateTime - */ - public function setStarted($value) - { - - $this->_validateDate('Started', $value); - if($this->_data['started'] === $value) - { - return; - } - - $this->_data['started'] = $value; - - $this->_setModified('started'); - } - - /** - * Set the value of Finished / finished. - * - * @param $value \DateTime - */ - public function setFinished($value) - { - - $this->_validateDate('Finished', $value); - if($this->_data['finished'] === $value) - { - return; - } - - $this->_data['finished'] = $value; - - $this->_setModified('finished'); - } - - /** - * Set the value of Plugins / plugins. - * - * @param $value string - */ - public function setPlugins($value) - { - - $this->_validateString('Plugins', $value); - if($this->_data['plugins'] === $value) - { - return; - } - - $this->_data['plugins'] = $value; - - $this->_setModified('plugins'); - } - - /** - * Get the Project model for this Build by Id. - * - * @uses \PHPCI\Store\ProjectStore::getById() - * @uses \PHPCI\Model\Project - * @return \PHPCI\Model\Project - */ - public function getProject() - { - $key = $this->getProjectId(); - - if(empty($key)) - { - return null; - } - - $cacheKey = 'Cache.Project.' . $key; - $rtn = $this->registry->get($cacheKey, null); - - if(empty($rtn)) - { - $rtn = \b8\Store\Factory::getStore('Project')->getById($key); - $this->registry->set($cacheKey, $rtn); - } - - return $rtn; - } - - /** - * Set Project - Accepts an ID, an array representing a Project or a Project model. - * - * @param $value mixed - */ - public function setProject($value) - { - // Is this an instance of Project? - if($value instanceof \PHPCI\Model\Project) - { - return $this->setProjectObject($value); - } - - // Is this an array representing a Project item? - if(is_array($value) && !empty($value['id'])) - { - return $this->setProjectId($value['id']); - } - - // Is this a scalar value representing the ID of this foreign key? - return $this->setProjectId($value); - } - - /** - * Set Project - Accepts a Project model. - * - * @param $value \PHPCI\Model\Project - */ - public function setProjectObject(\PHPCI\Model\Project $value) - { - return $this->setProjectId($value->getId()); - } - + /** + * @var array + */ + public static $sleepable = array(); + + /** + * @var string + */ + protected $tableName = 'build'; + + /** + * @var string + */ + protected $modelName = 'Build'; + + /** + * @var array + */ + protected $data = array( + 'id' => null, + 'project_id' => null, + 'commit_id' => null, + 'status' => null, + 'log' => null, + 'branch' => null, + 'created' => null, + 'started' => null, + 'finished' => null, + 'plugins' => null, + ); + + /** + * @var array + */ + protected $getters = array( + 'id' => 'getId', + 'project_id' => 'getProjectId', + 'commit_id' => 'getCommitId', + 'status' => 'getStatus', + 'log' => 'getLog', + 'branch' => 'getBranch', + 'created' => 'getCreated', + 'started' => 'getStarted', + 'finished' => 'getFinished', + 'plugins' => 'getPlugins', + 'Project' => 'getProject', + ); + + /** + * @var array + */ + protected $setters = array( + 'id' => 'setId', + 'project_id' => 'setProjectId', + 'commit_id' => 'setCommitId', + 'status' => 'setStatus', + 'log' => 'setLog', + 'branch' => 'setBranch', + 'created' => 'setCreated', + 'started' => 'setStarted', + 'finished' => 'setFinished', + 'plugins' => 'setPlugins', + 'Project' => 'setProject', + ); + + /** + * @var array + */ + public $columns = array( + 'id' => array( + 'type' => 'int', + 'length' => '11', + 'primary_key' => true, + 'auto_increment' => true, + ), + 'project_id' => array( + 'type' => 'int', + 'length' => '11', + ), + 'commit_id' => array( + 'type' => 'varchar', + 'length' => '50', + ), + 'status' => array( + 'type' => 'tinyint', + 'length' => '4', + ), + 'log' => array( + 'type' => 'text', + 'length' => '', + 'nullable' => true, + ), + 'branch' => array( + 'type' => 'varchar', + 'length' => '50', + ), + 'created' => array( + 'type' => 'datetime', + 'length' => '', + 'nullable' => true, + ), + 'started' => array( + 'type' => 'datetime', + 'length' => '', + 'nullable' => true, + ), + 'finished' => array( + 'type' => 'datetime', + 'length' => '', + 'nullable' => true, + ), + 'plugins' => array( + 'type' => 'text', + 'length' => '', + 'nullable' => true, + ), + ); + + /** + * @var array + */ + public $indexes = array( + 'PRIMARY' => array('unique' => true, 'columns' => 'id'), + 'project_id' => array('columns' => 'project_id'), + 'idx_status' => array('columns' => 'status'), + ); + + /** + * @var array + */ + public $foreignKeys = array( + 'build_ibfk_1' => array( + 'local_col' => 'project_id', + 'update' => 'CASCADE', + 'delete' => 'CASCADE', + 'table' => 'project', + 'col' => 'id' + ), + ); + + + /** + * Get the value of Id / id. + * + * @return int + */ + public function getId() + { + $rtn = $this->_data['id']; + + + return $rtn; + } + + /** + * Get the value of ProjectId / project_id. + * + * @return int + */ + public function getProjectId() + { + $rtn = $this->_data['project_id']; + + + return $rtn; + } + + /** + * Get the value of CommitId / commit_id. + * + * @return string + */ + public function getCommitId() + { + $rtn = $this->_data['commit_id']; + + + return $rtn; + } + + /** + * Get the value of Status / status. + * + * @return int + */ + public function getStatus() + { + $rtn = $this->_data['status']; + + + return $rtn; + } + + /** + * Get the value of Log / log. + * + * @return string + */ + public function getLog() + { + $rtn = $this->_data['log']; + + + return $rtn; + } + + /** + * Get the value of Branch / branch. + * + * @return string + */ + public function getBranch() + { + $rtn = $this->_data['branch']; + + + return $rtn; + } + + /** + * Get the value of Created / created. + * + * @return \DateTime + */ + public function getCreated() + { + $rtn = $this->_data['created']; + + + if (!empty($rtn)) { + $rtn = new \DateTime($rtn); + } + + + return $rtn; + } + + /** + * Get the value of Started / started. + * + * @return \DateTime + */ + public function getStarted() + { + $rtn = $this->_data['started']; + + + if (!empty($rtn)) { + $rtn = new \DateTime($rtn); + } + + + return $rtn; + } + + /** + * Get the value of Finished / finished. + * + * @return \DateTime + */ + public function getFinished() + { + $rtn = $this->_data['finished']; + + + if (!empty($rtn)) { + $rtn = new \DateTime($rtn); + } + + + return $rtn; + } + + /** + * Get the value of Plugins / plugins. + * + * @return string + */ + public function getPlugins() + { + $rtn = $this->_data['plugins']; + + + return $rtn; + } + + /** + * Set the value of Id / id. + * + * Must not be null. + * @param $value int + */ + public function setId($value) + { + $this->_validateNotNull('Id', $value); + $this->_validateInt('Id', $value); + if ($this->_data['id'] === $value) { + return; + } + + $this->_data['id'] = $value; + + $this->_setModified('id'); + } + + /** + * Set the value of ProjectId / project_id. + * + * Must not be null. + * @param $value int + */ + public function setProjectId($value) + { + $this->_validateNotNull('ProjectId', $value); + $this->_validateInt('ProjectId', $value); + if ($this->_data['project_id'] === $value) { + return; + } + + $this->_data['project_id'] = $value; + + $this->_setModified('project_id'); + } + + /** + * Set the value of CommitId / commit_id. + * + * Must not be null. + * @param $value string + */ + public function setCommitId($value) + { + $this->_validateNotNull('CommitId', $value); + $this->_validateString('CommitId', $value); + if ($this->_data['commit_id'] === $value) { + return; + } + + $this->_data['commit_id'] = $value; + + $this->_setModified('commit_id'); + } + + /** + * Set the value of Status / status. + * + * Must not be null. + * @param $value int + */ + public function setStatus($value) + { + $this->_validateNotNull('Status', $value); + $this->_validateInt('Status', $value); + if ($this->_data['status'] === $value) { + return; + } + + $this->_data['status'] = $value; + + $this->_setModified('status'); + } + + /** + * Set the value of Log / log. + * + * @param $value string + */ + public function setLog($value) + { + + $this->_validateString('Log', $value); + if ($this->_data['log'] === $value) { + return; + } + + $this->_data['log'] = $value; + + $this->_setModified('log'); + } + + /** + * Set the value of Branch / branch. + * + * Must not be null. + * @param $value string + */ + public function setBranch($value) + { + $this->_validateNotNull('Branch', $value); + $this->_validateString('Branch', $value); + if ($this->_data['branch'] === $value) { + return; + } + + $this->_data['branch'] = $value; + + $this->_setModified('branch'); + } + + /** + * Set the value of Created / created. + * + * @param $value \DateTime + */ + public function setCreated($value) + { + + $this->_validateDate('Created', $value); + if ($this->_data['created'] === $value) { + return; + } + + $this->_data['created'] = $value; + + $this->_setModified('created'); + } + + /** + * Set the value of Started / started. + * + * @param $value \DateTime + */ + public function setStarted($value) + { + + $this->_validateDate('Started', $value); + if ($this->_data['started'] === $value) { + return; + } + + $this->_data['started'] = $value; + + $this->_setModified('started'); + } + + /** + * Set the value of Finished / finished. + * + * @param $value \DateTime + */ + public function setFinished($value) + { + + $this->_validateDate('Finished', $value); + if ($this->_data['finished'] === $value) { + return; + } + + $this->_data['finished'] = $value; + + $this->_setModified('finished'); + } + + /** + * Set the value of Plugins / plugins. + * + * @param $value string + */ + public function setPlugins($value) + { + + $this->_validateString('Plugins', $value); + if ($this->_data['plugins'] === $value) { + return; + } + + $this->_data['plugins'] = $value; + + $this->_setModified('plugins'); + } + + /** + * Get the Project model for this Build by Id. + * + * @uses \PHPCI\Store\ProjectStore::getById() + * @uses \PHPCI\Model\Project + * @return \PHPCI\Model\Project + */ + public function getProject() + { + $key = $this->getProjectId(); + + if (empty($key)) { + return null; + } + + $cacheKey = 'Cache.Project.' . $key; + $rtn = $this->registry->get($cacheKey, null); + + if (empty($rtn)) { + $rtn = \b8\Store\Factory::getStore('Project')->getById($key); + $this->registry->set($cacheKey, $rtn); + } + + return $rtn; + } + + /** + * Set Project - Accepts an ID, an array representing a Project or a Project model. + * + * @param $value mixed + */ + public function setProject($value) + { + // Is this an instance of Project? + if ($value instanceof \PHPCI\Model\Project) { + return $this->setProjectObject($value); + } + + // Is this an array representing a Project item? + if (is_array($value) && !empty($value['id'])) { + return $this->setProjectId($value['id']); + } + + // Is this a scalar value representing the ID of this foreign key? + return $this->setProjectId($value); + } + + /** + * Set Project - Accepts a Project model. + * + * @param $value \PHPCI\Model\Project + */ + public function setProjectObject(\PHPCI\Model\Project $value) + { + return $this->setProjectId($value->getId()); + } } diff --git a/PHPCI/Model/Base/ProjectBase.php b/PHPCI/Model/Base/ProjectBase.php index 91ca4c12..431d06fc 100644 --- a/PHPCI/Model/Base/ProjectBase.php +++ b/PHPCI/Model/Base/ProjectBase.php @@ -5,6 +5,7 @@ */ namespace PHPCI\Model\Base; + use b8\Model; /** @@ -12,311 +13,304 @@ use b8\Model; */ class ProjectBase extends Model { - /** - * @var array - */ - public static $sleepable = array(); + /** + * @var array + */ + public static $sleepable = array(); - /** - * @var string - */ - protected $_tableName = 'project'; + /** + * @var string + */ + protected $tableName = 'project'; - /** - * @var string - */ - protected $_modelName = 'Project'; + /** + * @var string + */ + protected $modelName = 'Project'; - /** - * @var array - */ - protected $_data = array( - 'id' => null, - 'title' => null, - 'reference' => null, - 'git_key' => null, - 'type' => null, - 'token' => null, - ); + /** + * @var array + */ + protected $data = array( + 'id' => null, + 'title' => null, + 'reference' => null, + 'git_key' => null, + 'type' => null, + 'token' => null, + ); - /** - * @var array - */ - protected $_getters = array( - 'id' => 'getId', - 'title' => 'getTitle', - 'reference' => 'getReference', - 'git_key' => 'getGitKey', - 'type' => 'getType', - 'token' => 'getToken', - ); + /** + * @var array + */ + protected $getters = array( + 'id' => 'getId', + 'title' => 'getTitle', + 'reference' => 'getReference', + 'git_key' => 'getGitKey', + 'type' => 'getType', + 'token' => 'getToken', + ); - /** - * @var array - */ - protected $_setters = array( - 'id' => 'setId', - 'title' => 'setTitle', - 'reference' => 'setReference', - 'git_key' => 'setGitKey', - 'type' => 'setType', - 'token' => 'setToken', - ); + /** + * @var array + */ + protected $setters = array( + 'id' => 'setId', + 'title' => 'setTitle', + 'reference' => 'setReference', + 'git_key' => 'setGitKey', + 'type' => 'setType', + 'token' => 'setToken', + ); - /** - * @var array - */ - public $columns = array( - 'id' => array( - 'type' => 'int', - 'length' => '11', - 'primary_key' => true, - 'auto_increment' => true, - ), - 'title' => array( - 'type' => 'varchar', - 'length' => '250', - ), - 'reference' => array( - 'type' => 'varchar', - 'length' => '250', - ), - 'git_key' => array( - 'type' => 'text', - 'length' => '', - ), - 'type' => array( - 'type' => 'varchar', - 'length' => '50', - ), - 'token' => array( - 'type' => 'varchar', - 'length' => '50', - 'nullable' => true, - ), - ); + /** + * @var array + */ + public $columns = array( + 'id' => array( + 'type' => 'int', + 'length' => '11', + 'primary_key' => true, + 'auto_increment' => true, + ), + 'title' => array( + 'type' => 'varchar', + 'length' => '250', + ), + 'reference' => array( + 'type' => 'varchar', + 'length' => '250', + ), + 'git_key' => array( + 'type' => 'text', + 'length' => '', + ), + 'type' => array( + 'type' => 'varchar', + 'length' => '50', + ), + 'token' => array( + 'type' => 'varchar', + 'length' => '50', + 'nullable' => true, + ), + ); - /** - * @var array - */ - public $indexes = array( - 'PRIMARY' => array('unique' => true, 'columns' => 'id'), - ); + /** + * @var array + */ + public $indexes = array( + 'PRIMARY' => array('unique' => true, 'columns' => 'id'), + ); - /** - * @var array - */ - public $foreignKeys = array( - ); + /** + * @var array + */ + public $foreignKeys = array( + ); - /** - * Get the value of Id / id. - * - * @return int - */ - public function getId() - { - $rtn = $this->_data['id']; + /** + * Get the value of Id / id. + * + * @return int + */ + public function getId() + { + $rtn = $this->_data['id']; - - return $rtn; - } + + return $rtn; + } - /** - * Get the value of Title / title. - * - * @return string - */ - public function getTitle() - { - $rtn = $this->_data['title']; + /** + * Get the value of Title / title. + * + * @return string + */ + public function getTitle() + { + $rtn = $this->_data['title']; - - return $rtn; - } + + return $rtn; + } - /** - * Get the value of Reference / reference. - * - * @return string - */ - public function getReference() - { - $rtn = $this->_data['reference']; + /** + * Get the value of Reference / reference. + * + * @return string + */ + public function getReference() + { + $rtn = $this->_data['reference']; - - return $rtn; - } + + return $rtn; + } - /** - * Get the value of GitKey / git_key. - * - * @return string - */ - public function getGitKey() - { - $rtn = $this->_data['git_key']; + /** + * Get the value of GitKey / git_key. + * + * @return string + */ + public function getGitKey() + { + $rtn = $this->_data['git_key']; - - return $rtn; - } + + return $rtn; + } - /** - * Get the value of Type / type. - * - * @return string - */ - public function getType() - { - $rtn = $this->_data['type']; + /** + * Get the value of Type / type. + * + * @return string + */ + public function getType() + { + $rtn = $this->_data['type']; - - return $rtn; - } + + return $rtn; + } - /** - * Get the value of Token / token. - * - * @return string - */ - public function getToken() - { - $rtn = $this->_data['token']; + /** + * Get the value of Token / token. + * + * @return string + */ + public function getToken() + { + $rtn = $this->_data['token']; - - return $rtn; - } + + return $rtn; + } - /** - * Set the value of Id / id. - * - * Must not be null. - * @param $value int - */ - public function setId($value) - { - $this->_validateNotNull('Id', $value); - $this->_validateInt('Id', $value); - if($this->_data['id'] === $value) - { - return; - } + /** + * Set the value of Id / id. + * + * Must not be null. + * @param $value int + */ + public function setId($value) + { + $this->_validateNotNull('Id', $value); + $this->_validateInt('Id', $value); + if ($this->_data['id'] === $value) { + return; + } - $this->_data['id'] = $value; + $this->_data['id'] = $value; - $this->_setModified('id'); - } + $this->_setModified('id'); + } - /** - * Set the value of Title / title. - * - * Must not be null. - * @param $value string - */ - public function setTitle($value) - { - $this->_validateNotNull('Title', $value); - $this->_validateString('Title', $value); - if($this->_data['title'] === $value) - { - return; - } + /** + * Set the value of Title / title. + * + * Must not be null. + * @param $value string + */ + public function setTitle($value) + { + $this->_validateNotNull('Title', $value); + $this->_validateString('Title', $value); + if ($this->_data['title'] === $value) { + return; + } - $this->_data['title'] = $value; + $this->_data['title'] = $value; - $this->_setModified('title'); - } + $this->_setModified('title'); + } - /** - * Set the value of Reference / reference. - * - * Must not be null. - * @param $value string - */ - public function setReference($value) - { - $this->_validateNotNull('Reference', $value); - $this->_validateString('Reference', $value); - if($this->_data['reference'] === $value) - { - return; - } + /** + * Set the value of Reference / reference. + * + * Must not be null. + * @param $value string + */ + public function setReference($value) + { + $this->_validateNotNull('Reference', $value); + $this->_validateString('Reference', $value); + if ($this->_data['reference'] === $value) { + return; + } - $this->_data['reference'] = $value; + $this->_data['reference'] = $value; - $this->_setModified('reference'); - } + $this->_setModified('reference'); + } - /** - * Set the value of GitKey / git_key. - * - * Must not be null. - * @param $value string - */ - public function setGitKey($value) - { - $this->_validateNotNull('GitKey', $value); - $this->_validateString('GitKey', $value); - if($this->_data['git_key'] === $value) - { - return; - } + /** + * Set the value of GitKey / git_key. + * + * Must not be null. + * @param $value string + */ + public function setGitKey($value) + { + $this->_validateNotNull('GitKey', $value); + $this->_validateString('GitKey', $value); + if ($this->_data['git_key'] === $value) { + return; + } - $this->_data['git_key'] = $value; + $this->_data['git_key'] = $value; - $this->_setModified('git_key'); - } + $this->_setModified('git_key'); + } - /** - * Set the value of Type / type. - * - * Must not be null. - * @param $value string - */ - public function setType($value) - { - $this->_validateNotNull('Type', $value); - $this->_validateString('Type', $value); - if($this->_data['type'] === $value) - { - return; - } + /** + * Set the value of Type / type. + * + * Must not be null. + * @param $value string + */ + public function setType($value) + { + $this->_validateNotNull('Type', $value); + $this->_validateString('Type', $value); + if ($this->_data['type'] === $value) { + return; + } - $this->_data['type'] = $value; + $this->_data['type'] = $value; - $this->_setModified('type'); - } + $this->_setModified('type'); + } - /** - * Set the value of Token / token. - * - * @param $value string - */ - public function setToken($value) - { + /** + * Set the value of Token / token. + * + * @param $value string + */ + public function setToken($value) + { - $this->_validateString('Token', $value); - if($this->_data['token'] === $value) - { - return; - } + $this->_validateString('Token', $value); + if ($this->_data['token'] === $value) { + return; + } - $this->_data['token'] = $value; + $this->_data['token'] = $value; - $this->_setModified('token'); - } - - /** - * Get Build models by ProjectId for this Project. - * - * @uses \PHPCI\Store\BuildStore::getByProjectId() - * @uses \PHPCI\Model\Build - * @return \PHPCI\Model\Build[] - */ - public function getProjectBuilds() - { - return \b8\Store\Factory::getStore('Build')->getByProjectId($this->getId()); - } + $this->_setModified('token'); + } + /** + * Get Build models by ProjectId for this Project. + * + * @uses \PHPCI\Store\BuildStore::getByProjectId() + * @uses \PHPCI\Model\Build + * @return \PHPCI\Model\Build[] + */ + public function getProjectBuilds() + { + return \b8\Store\Factory::getStore('Build')->getByProjectId($this->getId()); + } } diff --git a/PHPCI/Model/Base/UserBase.php b/PHPCI/Model/Base/UserBase.php index 5863a61d..cf2ef88b 100644 --- a/PHPCI/Model/Base/UserBase.php +++ b/PHPCI/Model/Base/UserBase.php @@ -5,6 +5,7 @@ */ namespace PHPCI\Model\Base; + use b8\Model; /** @@ -12,260 +13,254 @@ use b8\Model; */ class UserBase extends Model { - /** - * @var array - */ - public static $sleepable = array(); + /** + * @var array + */ + public static $sleepable = array(); - /** - * @var string - */ - protected $_tableName = 'user'; + /** + * @var string + */ + protected $tableName = 'user'; - /** - * @var string - */ - protected $_modelName = 'User'; + /** + * @var string + */ + protected $modelName = 'User'; - /** - * @var array - */ - protected $_data = array( - 'id' => null, - 'email' => null, - 'hash' => null, - 'is_admin' => null, - 'name' => null, - ); + /** + * @var array + */ + protected $data = array( + 'id' => null, + 'email' => null, + 'hash' => null, + 'is_admin' => null, + 'name' => null, + ); - /** - * @var array - */ - protected $_getters = array( - 'id' => 'getId', - 'email' => 'getEmail', - 'hash' => 'getHash', - 'is_admin' => 'getIsAdmin', - 'name' => 'getName', - ); + /** + * @var array + */ + protected $getters = array( + 'id' => 'getId', + 'email' => 'getEmail', + 'hash' => 'getHash', + 'is_admin' => 'getIsAdmin', + 'name' => 'getName', + ); - /** - * @var array - */ - protected $_setters = array( - 'id' => 'setId', - 'email' => 'setEmail', - 'hash' => 'setHash', - 'is_admin' => 'setIsAdmin', - 'name' => 'setName', - ); + /** + * @var array + */ + protected $setters = array( + 'id' => 'setId', + 'email' => 'setEmail', + 'hash' => 'setHash', + 'is_admin' => 'setIsAdmin', + 'name' => 'setName', + ); - /** - * @var array - */ - public $columns = array( - 'id' => array( - 'type' => 'int', - 'length' => '11', - 'primary_key' => true, - 'auto_increment' => true, - ), - 'email' => array( - 'type' => 'varchar', - 'length' => '250', - ), - 'hash' => array( - 'type' => 'varchar', - 'length' => '250', - ), - 'is_admin' => array( - 'type' => 'tinyint', - 'length' => '1', - ), - 'name' => array( - 'type' => 'varchar', - 'length' => '250', - ), - ); + /** + * @var array + */ + public $columns = array( + 'id' => array( + 'type' => 'int', + 'length' => '11', + 'primary_key' => true, + 'auto_increment' => true, + ), + 'email' => array( + 'type' => 'varchar', + 'length' => '250', + ), + 'hash' => array( + 'type' => 'varchar', + 'length' => '250', + ), + 'is_admin' => array( + 'type' => 'tinyint', + 'length' => '1', + ), + 'name' => array( + 'type' => 'varchar', + 'length' => '250', + ), + ); - /** - * @var array - */ - public $indexes = array( - 'PRIMARY' => array('unique' => true, 'columns' => 'id'), - 'idx_email' => array('unique' => true, 'columns' => 'email'), - ); + /** + * @var array + */ + public $indexes = array( + 'PRIMARY' => array('unique' => true, 'columns' => 'id'), + 'idx_email' => array('unique' => true, 'columns' => 'email'), + ); - /** - * @var array - */ - public $foreignKeys = array( - ); + /** + * @var array + */ + public $foreignKeys = array( + ); - /** - * Get the value of Id / id. - * - * @return int - */ - public function getId() - { - $rtn = $this->_data['id']; + /** + * Get the value of Id / id. + * + * @return int + */ + public function getId() + { + $rtn = $this->_data['id']; - - return $rtn; - } + + return $rtn; + } - /** - * Get the value of Email / email. - * - * @return string - */ - public function getEmail() - { - $rtn = $this->_data['email']; + /** + * Get the value of Email / email. + * + * @return string + */ + public function getEmail() + { + $rtn = $this->_data['email']; - - return $rtn; - } + + return $rtn; + } - /** - * Get the value of Hash / hash. - * - * @return string - */ - public function getHash() - { - $rtn = $this->_data['hash']; + /** + * Get the value of Hash / hash. + * + * @return string + */ + public function getHash() + { + $rtn = $this->_data['hash']; - - return $rtn; - } + + return $rtn; + } - /** - * Get the value of IsAdmin / is_admin. - * - * @return int - */ - public function getIsAdmin() - { - $rtn = $this->_data['is_admin']; + /** + * Get the value of IsAdmin / is_admin. + * + * @return int + */ + public function getIsAdmin() + { + $rtn = $this->_data['is_admin']; - - return $rtn; - } + + return $rtn; + } - /** - * Get the value of Name / name. - * - * @return string - */ - public function getName() - { - $rtn = $this->_data['name']; + /** + * Get the value of Name / name. + * + * @return string + */ + public function getName() + { + $rtn = $this->_data['name']; - - return $rtn; - } + + return $rtn; + } - /** - * Set the value of Id / id. - * - * Must not be null. - * @param $value int - */ - public function setId($value) - { - $this->_validateNotNull('Id', $value); - $this->_validateInt('Id', $value); - if($this->_data['id'] === $value) - { - return; - } + /** + * Set the value of Id / id. + * + * Must not be null. + * @param $value int + */ + public function setId($value) + { + $this->_validateNotNull('Id', $value); + $this->_validateInt('Id', $value); + if ($this->_data['id'] === $value) { + return; + } - $this->_data['id'] = $value; + $this->_data['id'] = $value; - $this->_setModified('id'); - } + $this->_setModified('id'); + } - /** - * Set the value of Email / email. - * - * Must not be null. - * @param $value string - */ - public function setEmail($value) - { - $this->_validateNotNull('Email', $value); - $this->_validateString('Email', $value); - if($this->_data['email'] === $value) - { - return; - } + /** + * Set the value of Email / email. + * + * Must not be null. + * @param $value string + */ + public function setEmail($value) + { + $this->_validateNotNull('Email', $value); + $this->_validateString('Email', $value); + if ($this->_data['email'] === $value) { + return; + } - $this->_data['email'] = $value; + $this->_data['email'] = $value; - $this->_setModified('email'); - } + $this->_setModified('email'); + } - /** - * Set the value of Hash / hash. - * - * Must not be null. - * @param $value string - */ - public function setHash($value) - { - $this->_validateNotNull('Hash', $value); - $this->_validateString('Hash', $value); - if($this->_data['hash'] === $value) - { - return; - } + /** + * Set the value of Hash / hash. + * + * Must not be null. + * @param $value string + */ + public function setHash($value) + { + $this->_validateNotNull('Hash', $value); + $this->_validateString('Hash', $value); + if ($this->_data['hash'] === $value) { + return; + } - $this->_data['hash'] = $value; + $this->_data['hash'] = $value; - $this->_setModified('hash'); - } + $this->_setModified('hash'); + } - /** - * Set the value of IsAdmin / is_admin. - * - * Must not be null. - * @param $value int - */ - public function setIsAdmin($value) - { - $this->_validateNotNull('IsAdmin', $value); - $this->_validateInt('IsAdmin', $value); - if($this->_data['is_admin'] === $value) - { - return; - } + /** + * Set the value of IsAdmin / is_admin. + * + * Must not be null. + * @param $value int + */ + public function setIsAdmin($value) + { + $this->_validateNotNull('IsAdmin', $value); + $this->_validateInt('IsAdmin', $value); + if ($this->_data['is_admin'] === $value) { + return; + } - $this->_data['is_admin'] = $value; + $this->_data['is_admin'] = $value; - $this->_setModified('is_admin'); - } + $this->_setModified('is_admin'); + } - /** - * Set the value of Name / name. - * - * Must not be null. - * @param $value string - */ - public function setName($value) - { - $this->_validateNotNull('Name', $value); - $this->_validateString('Name', $value); - if($this->_data['name'] === $value) - { - return; - } + /** + * Set the value of Name / name. + * + * Must not be null. + * @param $value string + */ + public function setName($value) + { + $this->_validateNotNull('Name', $value); + $this->_validateString('Name', $value); + if ($this->_data['name'] === $value) { + return; + } - $this->_data['name'] = $value; - - $this->_setModified('name'); - } + $this->_data['name'] = $value; + $this->_setModified('name'); + } } diff --git a/PHPCI/Model/Build.php b/PHPCI/Model/Build.php index bd6677ad..5230b42c 100644 --- a/PHPCI/Model/Build.php +++ b/PHPCI/Model/Build.php @@ -9,36 +9,34 @@ namespace PHPCI\Model; -require_once(APPLICATION_PATH . 'PHPCI/Model/Base/BuildBase.php'); - -use PHPCI\Model\Base\BuildBase, - PHPCI\Builder; +use PHPCI\Model\Base\BuildBase; +use PHPCI\Builder; /** * Build Model -* @uses PHPCI\Model\Base\BuildBase +* @uses PHPCI\Model\Base\BuildBase * @author Dan Cryer * @package PHPCI * @subpackage Core */ class Build extends BuildBase { - public function getCommitLink() - { - return '#'; - } + public function getCommitLink() + { + return '#'; + } - public function getBranchLink() - { - return '#'; - } + public function getBranchLink() + { + return '#'; + } - public function sendStatusPostback() - { - return; - } + public function sendStatusPostback() + { + return; + } - public function createWorkingCopy(Builder $builder, $buildPath) - { - } + public function createWorkingCopy(Builder $builder, $buildPath) + { + } } diff --git a/PHPCI/Model/Build/BitbucketBuild.php b/PHPCI/Model/Build/BitbucketBuild.php index 9631788d..485c66e8 100644 --- a/PHPCI/Model/Build/BitbucketBuild.php +++ b/PHPCI/Model/Build/BitbucketBuild.php @@ -8,8 +8,9 @@ */ namespace PHPCI\Model\Build; -use PHPCI\Model\Build, - PHPCI\Model\Build\RemoteGitBuild; + +use PHPCI\Model\Build; +use PHPCI\Model\Build\RemoteGitBuild; /** * BitBucket Build Model @@ -19,25 +20,24 @@ use PHPCI\Model\Build, */ class BitbucketBuild extends RemoteGitBuild { - public function getCommitLink() - { - return 'https://bitbucket.org/' . $this->getProject()->getReference() . '/commits/' . $this->getCommitId(); - } + public function getCommitLink() + { + return 'https://bitbucket.org/' . $this->getProject()->getReference() . '/commits/' . $this->getCommitId(); + } - public function getBranchLink() - { - return 'https://bitbucket.org/' . $this->getProject()->getReference() . '/src/?at=' . $this->getBranch(); - } + public function getBranchLink() + { + return 'https://bitbucket.org/' . $this->getProject()->getReference() . '/src/?at=' . $this->getBranch(); + } - protected function getCloneUrl() - { - $key = trim($this->getProject()->getGitKey()); + protected function getCloneUrl() + { + $key = trim($this->getProject()->getGitKey()); - if(!empty($key)) { - return 'git@bitbucket.org:' . $this->getProject()->getReference() . '.git'; - } - else { - return 'https://bitbucket.org/' . $this->getProject()->getReference() . '.git'; - } - } + if (!empty($key)) { + return 'git@bitbucket.org:' . $this->getProject()->getReference() . '.git'; + } else { + return 'https://bitbucket.org/' . $this->getProject()->getReference() . '.git'; + } + } } diff --git a/PHPCI/Model/Build/GithubBuild.php b/PHPCI/Model/Build/GithubBuild.php index 283823e1..e08e31f4 100644 --- a/PHPCI/Model/Build/GithubBuild.php +++ b/PHPCI/Model/Build/GithubBuild.php @@ -8,6 +8,7 @@ */ namespace PHPCI\Model\Build; + use PHPCI\Model\Build\RemoteGitBuild; /** @@ -18,67 +19,65 @@ use PHPCI\Model\Build\RemoteGitBuild; */ class GithubBuild extends RemoteGitBuild { - public function getCommitLink() - { - return 'https://github.com/' . $this->getProject()->getReference() . '/commit/' . $this->getCommitId(); - } + public function getCommitLink() + { + return 'https://github.com/' . $this->getProject()->getReference() . '/commit/' . $this->getCommitId(); + } - public function getBranchLink() - { - return 'https://github.com/' . $this->getProject()->getReference() . '/tree/' . $this->getBranch(); - } + public function getBranchLink() + { + return 'https://github.com/' . $this->getProject()->getReference() . '/tree/' . $this->getBranch(); + } - public function sendStatusPostback() - { - $project = $this->getProject(); + public function sendStatusPostback() + { + $project = $this->getProject(); - // The postback will only work if we have an access token. - if(!$project->getToken()) { - return; - } + // The postback will only work if we have an access token. + if (!$project->getToken()) { + return; + } - $url = 'https://api.github.com/repos/'.$project->getReference().'/statuses/'.$this->getCommitId(); - $http = new \b8\HttpClient(); + $url = 'https://api.github.com/repos/'.$project->getReference().'/statuses/'.$this->getCommitId(); + $http = new \b8\HttpClient(); - switch($this->getStatus()) - { - case 0: - case 1: - $status = 'pending'; - break; + switch($this->getStatus()) + { + case 0: + case 1: + $status = 'pending'; + break; + case 2: + $status = 'success'; + break; + case 3: + $status = 'failure'; + break; + default: + $status = 'error'; + break; + } - case 2: - $status = 'success'; - break; + $url = \b8\Registry::getInstance()->get('install_url'); + $params = array( 'state' => $status, + 'target_url' => $url . '/build/view/' . $this->getId()); + $headers = array( + 'Authorization: token ' . $project->getToken(), + 'Content-Type: application/x-www-form-urlencoded' + ); - case 3: - $status = 'failure'; - break; + $http->setHeaders($headers); + $http->request('POST', $url, json_encode($params)); + } - default: - $status = 'error'; - break; - } + protected function getCloneUrl() + { + $key = trim($this->getProject()->getGitKey()); - $params = array( 'state' => $status, - 'target_url' => \b8\Registry::getInstance()->get('install_url') . '/build/view/' . $this->getId()); - - $http->setHeaders(array( - 'Authorization: token ' . $project->getToken(), - 'Content-Type: application/x-www-form-urlencoded' - )); - $http->request('POST', $url, json_encode($params)); - } - - protected function getCloneUrl() - { - $key = trim($this->getProject()->getGitKey()); - - if(!empty($key)) { - return 'git@github.com:' . $this->getProject()->getReference() . '.git'; - } - else { - return 'https://github.com/' . $this->getProject()->getReference() . '.git'; - } - } + if (!empty($key)) { + return 'git@github.com:' . $this->getProject()->getReference() . '.git'; + } else { + return 'https://github.com/' . $this->getProject()->getReference() . '.git'; + } + } } diff --git a/PHPCI/Model/Build/LocalBuild.php b/PHPCI/Model/Build/LocalBuild.php index 9a4374be..51c25145 100644 --- a/PHPCI/Model/Build/LocalBuild.php +++ b/PHPCI/Model/Build/LocalBuild.php @@ -8,9 +8,10 @@ */ namespace PHPCI\Model\Build; -use PHPCI\Model\Build, - PHPCI\Builder, - Symfony\Component\Yaml\Parser as YamlParser; + +use PHPCI\Model\Build; +use PHPCI\Builder; +use Symfony\Component\Yaml\Parser as YamlParser; /** * Local Build Model @@ -20,39 +21,38 @@ use PHPCI\Model\Build, */ class LocalBuild extends Build { - public function createWorkingCopy(Builder $builder, $buildPath) - { - $reference = $this->getProject()->getReference(); - $reference = substr($reference, -1) == '/' ? substr($reference, 0, -1) : $reference; - $buildPath = substr($buildPath, 0, -1); - $yamlParser = new YamlParser(); + public function createWorkingCopy(Builder $builder, $buildPath) + { + $reference = $this->getProject()->getReference(); + $reference = substr($reference, -1) == '/' ? substr($reference, 0, -1) : $reference; + $buildPath = substr($buildPath, 0, -1); + $yamlParser = new YamlParser(); - if(!is_file($reference . '/phpci.yml')) { - $builder->logFailure('Project does not contain a phpci.yml file.'); - return false; - } + if (!is_file($reference . '/phpci.yml')) { + $builder->logFailure('Project does not contain a phpci.yml file.'); + return false; + } - $yamlFile = file_get_contents($reference . '/phpci.yml'); - $builder->setConfigArray($yamlParser->parse($yamlFile)); + $yamlFile = file_get_contents($reference . '/phpci.yml'); + $builder->setConfigArray($yamlParser->parse($yamlFile)); - $buildSettings = $builder->getConfig('build_settings'); + $buildSettings = $builder->getConfig('build_settings'); - if(isset($buildSettings['prefer_symlink']) && $buildSettings['prefer_symlink'] === true) { - if(is_link($buildPath) && is_file($buildPath)) { - unlink($buildPath); - } + if (isset($buildSettings['prefer_symlink']) && $buildSettings['prefer_symlink'] === true) { + if (is_link($buildPath) && is_file($buildPath)) { + unlink($buildPath); + } - $builder->log(sprintf('Symlinking: %s to %s',$reference, $buildPath)); + $builder->log(sprintf('Symlinking: %s to %s', $reference, $buildPath)); - if(!symlink($reference, $buildPath)) { - $builder->logFailure('Failed to symlink.'); - return false; - } - } - else { - $builder->executeCommand('cp -Rf "%s" "%s/"', $reference, $buildPath); - } + if (!symlink($reference, $buildPath)) { + $builder->logFailure('Failed to symlink.'); + return false; + } + } else { + $builder->executeCommand('cp -Rf "%s" "%s/"', $reference, $buildPath); + } - return true; - } + return true; + } } diff --git a/PHPCI/Model/Build/RemoteGitBuild.php b/PHPCI/Model/Build/RemoteGitBuild.php index 8f10c713..e11dde92 100644 --- a/PHPCI/Model/Build/RemoteGitBuild.php +++ b/PHPCI/Model/Build/RemoteGitBuild.php @@ -8,9 +8,10 @@ */ namespace PHPCI\Model\Build; -use PHPCI\Model\Build, - PHPCI\Builder, - Symfony\Component\Yaml\Parser as YamlParser; + +use PHPCI\Model\Build; +use PHPCI\Builder; +use Symfony\Component\Yaml\Parser as YamlParser; /** * Remote Git Build Model @@ -20,55 +21,55 @@ use PHPCI\Model\Build, */ abstract class RemoteGitBuild extends Build { - abstract protected function getCloneUrl(); + abstract protected function getCloneUrl(); - public function createWorkingCopy(Builder $builder, $buildPath) - { - $yamlParser = new YamlParser(); - $success = true; - $key = trim($this->getProject()->getGitKey()); + public function createWorkingCopy(Builder $builder, $buildPath) + { + $yamlParser = new YamlParser(); + $success = true; + $key = trim($this->getProject()->getGitKey()); - if(!empty($key)) { - $success = $this->cloneBySsh($builder, $buildPath); - } - else { - $success = $this->cloneByHttp($builder, $buildPath); - } + if (!empty($key)) { + $success = $this->cloneBySsh($builder, $buildPath); + } else { + $success = $this->cloneByHttp($builder, $buildPath); + } - if(!$success) { - $builder->logFailure('Failed to clone remote git repository.'); - return false; - } + if (!$success) { + $builder->logFailure('Failed to clone remote git repository.'); + return false; + } - if(!is_file($buildPath . 'phpci.yml')) { - $builder->logFailure('Project does not contain a phpci.yml file.'); - return false; - } + if (!is_file($buildPath . 'phpci.yml')) { + $builder->logFailure('Project does not contain a phpci.yml file.'); + return false; + } - $yamlFile = file_get_contents($buildPath . 'phpci.yml'); - $builder->setConfigArray($yamlParser->parse($yamlFile)); + $yamlFile = file_get_contents($buildPath . 'phpci.yml'); + $builder->setConfigArray($yamlParser->parse($yamlFile)); - return true; - } + return true; + } - protected function cloneByHttp(Builder $builder, $to) - { - return $builder->executeCommand('git clone -b %s %s "%s"', $this->getBranch(), $this->getCloneUrl(), $to); - } + protected function cloneByHttp(Builder $builder, $to) + { + return $builder->executeCommand('git clone -b %s %s "%s"', $this->getBranch(), $this->getCloneUrl(), $to); + } - protected function cloneBySsh(Builder $builder, $to) - { - // Copy the project's keyfile to disk: - $keyFile = realpath($to) . '.key'; - file_put_contents($keyFile, $this->getProject()->getGitKey()); - chmod($keyFile, 0600); + protected function cloneBySsh(Builder $builder, $to) + { + // Copy the project's keyfile to disk: + $keyFile = realpath($to) . '.key'; + file_put_contents($keyFile, $this->getProject()->getGitKey()); + chmod($keyFile, 0600); - // Use the key file to do an SSH clone: - $success = $builder->executeCommand('ssh-agent ssh-add "%s" && git clone -b %s %s "%s" && ssh-agent -k', $keyFile, $build->getBranch(), $this->getCloneUrl(), $to); - - // Remove the key file: - unlink($keyFile); + // Use the key file to do an SSH clone: + $cmd = 'ssh-agent ssh-add "%s" && git clone -b %s %s "%s" && ssh-agent -k'; + $success = $builder->executeCommand($cmd, $keyFile, $build->getBranch(), $this->getCloneUrl(), $to); + + // Remove the key file: + unlink($keyFile); - return $success; - } + return $success; + } } diff --git a/PHPCI/Model/Project.php b/PHPCI/Model/Project.php index df25bd58..be1c808b 100644 --- a/PHPCI/Model/Project.php +++ b/PHPCI/Model/Project.php @@ -9,13 +9,11 @@ namespace PHPCI\Model; -require_once(APPLICATION_PATH . 'PHPCI/Model/Base/ProjectBase.php'); - use PHPCI\Model\Base\ProjectBase; /** * Project Model -* @uses PHPCI\Model\Base\ProjectBase +* @uses PHPCI\Model\Base\ProjectBase * @author Dan Cryer * @package PHPCI * @subpackage Core diff --git a/PHPCI/Model/User.php b/PHPCI/Model/User.php index fc3ae741..5accf029 100644 --- a/PHPCI/Model/User.php +++ b/PHPCI/Model/User.php @@ -9,18 +9,16 @@ namespace PHPCI\Model; -require_once(APPLICATION_PATH . 'PHPCI/Model/Base/UserBase.php'); - use PHPCI\Model\Base\UserBase; /** * User Model -* @uses PHPCI\Model\Base\UserBase +* @uses PHPCI\Model\Base\UserBase * @author Dan Cryer * @package PHPCI * @subpackage Core */ class User extends UserBase { - // This class has been left blank so that you can modify it - changes in this file will not be overwritten. + // This class has been left blank so that you can modify it - changes in this file will not be overwritten. } diff --git a/PHPCI/Store/BuildStore.php b/PHPCI/Store/BuildStore.php index 7b039516..46097d1f 100644 --- a/PHPCI/Store/BuildStore.php +++ b/PHPCI/Store/BuildStore.php @@ -14,9 +14,11 @@ require_once(APPLICATION_PATH . 'PHPCI/Store/Base/BuildStoreBase.php'); use PHPCI\Store\Base\BuildStoreBase; /** - * Build Store - * @uses PHPCI\Store\Base\BuildStoreBase - */ +* Build Store +* @author Dan Cryer +* @package PHPCI +* @subpackage Core +*/ class BuildStore extends BuildStoreBase { // This class has been left blank so that you can modify it - changes in this file will not be overwritten.