*/ class BuildFactory { /** * @param $buildId * @return Build * @throws \Exception */ public static function getBuildById($buildId) { $build = Factory::getStore('Build')->getById($buildId); if (empty($build)) { throw new \Exception('Build ID ' . $buildId . ' does not exist.'); } return self::getBuild($build); } /** * Takes a generic build and returns a type-specific build model. * @param Build $base The build from which to get a more specific build type. * @return Build */ public static function getBuild(Build $base) { switch($base->getProject()->getType()) { case 'remote': $type = 'RemoteGitBuild'; break; case 'local': $type = 'LocalBuild'; break; case 'github': $type = 'GithubBuild'; break; case 'bitbucket': $type = 'BitbucketBuild'; break; case 'gitlab': $type = 'GitlabBuild'; break; case 'hg': $type = 'MercurialBuild'; break; case 'svn': $type = 'SubversionBuild'; break; } $type = '\\PHPCI\\Model\\Build\\' . $type; return new $type($base->getDataArray()); } }