diff --git a/PHPCI/Model/Base/ProjectBase.php b/PHPCI/Model/Base/ProjectBase.php index e3e12ecc..c16d3ee5 100644 --- a/PHPCI/Model/Base/ProjectBase.php +++ b/PHPCI/Model/Base/ProjectBase.php @@ -215,11 +215,19 @@ class ProjectBase extends Model /** * Get the value of AccessInformation / access_information. * + * @param string|null $key Key of desired information + * * @return string */ - public function getAccessInformation() + public function getAccessInformation($key = null) { - $rtn = $this->data['access_information']; + if (is_null($key)) { + $rtn = $this->data['access_information']; + } else if (isset($this->data['access_information'][$key])) { + $rtn = $this->data['access_information'][$key]; + } else { + $rtn = null; + } return $rtn; } diff --git a/PHPCI/Model/Build/GitlabBuild.php b/PHPCI/Model/Build/GitlabBuild.php index f3f75ebe..98be17c8 100644 --- a/PHPCI/Model/Build/GitlabBuild.php +++ b/PHPCI/Model/Build/GitlabBuild.php @@ -25,7 +25,7 @@ class GitlabBuild extends RemoteGitBuild */ public function getCommitLink() { - $domain = $this->getProject()->getAccessInformation()["domain"]; + $domain = $this->getProject()->getAccessInformation("domain"); return 'http://' . $domain . '/' . $this->getProject()->getReference() . '/commit/' . $this->getCommitId(); } @@ -34,7 +34,7 @@ class GitlabBuild extends RemoteGitBuild */ public function getBranchLink() { - $domain = $this->getProject()->getAccessInformation()["domain"]; + $domain = $this->getProject()->getAccessInformation("domain"); return 'http://' . $domain . '/' . $this->getProject()->getReference() . '/tree/' . $this->getBranch(); } @@ -46,8 +46,8 @@ class GitlabBuild extends RemoteGitBuild $key = trim($this->getProject()->getGitKey()); if (!empty($key)) { - $user = $this->getProject()->getAccessInformation()["user"]; - $domain = $this->getProject()->getAccessInformation()["domain"]; + $user = $this->getProject()->getAccessInformation("user"); + $domain = $this->getProject()->getAccessInformation("domain"); return $user . '@' . $domain . ':' . $this->getProject()->getReference() . '.git'; } }