/** * Instantiate a new local git branch object * * @param string $branch * @param Sadekbaroud\Gitorade\Branches\BranchRemote $remote The remote branch representation of this local branch. * Used only if you need to push this local branch to remote. * @throws GitException */ public function __construct($branch, $remote = NULL) { if (strpos($branch, '/') !== FALSE) { throw new GitException("BranchLocal '{$branch}' cannot contain a /"); } if (!is_null($remote)) { $this->setRemote($remote); } parent::__construct($branch); }
public function __construct($branch) { parent::__construct($branch); if (strpos($branch, "{$this->prefix}/") !== 0) { throw new GitException("The BranchRemote must begin with '{$this->prefix}/'"); } $exploded = explode('/', $branch, 3); if (count($exploded) < 3) { throw new GitException("The BranchRemote name '{$branch}' must be in the format remotes/alias/branchname"); } // Set up the local variables $this->alias = $exploded[1]; $this->branchOnly = $exploded[2]; $this->mergeName = $this->branchOnly; }