/** * Fetches the branches via the `git branch` command. * * @param boolean $onlyRemote * Whether to fetch only remote branches, defaults to false which returns * all branches. * * @return array */ public function fetchBranches($onlyRemote = false) { $this->git->clearOutput(); $options = $onlyRemote ? array('r' => true) : array('a' => true); $output = (string) $this->git->branch($options); $branches = preg_split("/\r\n|\n|\r/", rtrim($output)); return array_map(array($this, 'trimBranch'), $branches); }