public function getBranches($which = self::BRANCHES_LOCAL)
    {
        $which       = (int)$which;
        $arguments  = array(
            '--no-color'
        );

        $local  = (($which & self::BRANCHES_LOCAL) == self::BRANCHES_LOCAL);
        $remote = (($which & self::BRANCHES_REMOTE) == self::BRANCHES_REMOTE);

        if ($local && $remote) {
            $arguments[] = '-a';
        } else if ($remote) {
            $arguments[] = '-r';
        }

        /** @var $result CallResult */
        $result = $this->getGit()->{'branch'}($this->getRepositoryPath(), $arguments);
        $result->assertSuccess(
            sprintf('Cannot retrieve branch from "%s"', $this->getRepositoryPath())
        );

        $output = rtrim($result->getStdOut());
        if (empty($output)) {
            return array();
        }

        $branches = array_map(function($b) {
            $line   = rtrim($b);
            if (strpos($line, '* ') === 0) {
                $line   = substr($line, 2);
            }
            $line   = ltrim($line);
            return $line;
        }, explode("\n", $output));
        return $branches;
    }
public function getBranches($which = self::BRANCHES_LOCAL)
    {
        $which       = (int)$which;
        $arguments  = array(
            '--no-color'
        );

        $local  = (($which & self::BRANCHES_LOCAL) == self::BRANCHES_LOCAL);
        $remote = (($which & self::BRANCHES_REMOTE) == self::BRANCHES_REMOTE);

        if ($local && $remote) {
            $arguments[] = '-a';
        } else if ($remote) {
            $arguments[] = '-r';
        }

        /** @var $result CallResult */
        $result = $this->getGit()->{'branch'}($this->getRepositoryPath(), $arguments);
        $result->assertSuccess(
            sprintf('Cannot retrieve branch from "%s"', $this->getRepositoryPath())
        );

        $output = rtrim($result->getStdOut());
        if (empty($output)) {
            return array();
        }

        $branches = array_map(function($b) {
            $line   = rtrim($b);
            if (strpos($line, '* ') === 0) {
                $line   = substr($line, 2);
            }
            $line   = ltrim($line);
            return $line;
        }, explode("\n", $output));
        return $branches;
    }
public function getBranches ( $ which = self :: BRANCHES_LOCAL ) { $ which = ( int ) $ which ; $ arguments = array ( '--no-color' ) ; $ local = ( ( $ which & self :: BRANCHES_LOCAL ) == self :: BRANCHES_LOCAL ) ; $ remote = ( ( $ which & self :: BRANCHES_REMOTE ) == self :: BRANCHES_REMOTE ) ; if ( $ local && $ remote ) { $ arguments [ ] = '-a' ; } else if ( $ remote ) { $ arguments [ ] = '-r' ; } /** @var $result CallResult */ $ result = $ this -> getGit ( ) -> { 'branch' } ( $ this -> getRepositoryPath ( ) , $ arguments ) ; $ result -> assertSuccess ( sprintf ( 'Cannot retrieve branch from "%s"' , $ this -> getRepositoryPath ( ) ) ) ; $ output = rtrim ( $ result -> getStdOut ( ) ) ; if ( empty ( $ output ) ) { return array ( ) ; } $ branches = array_map ( function ( $ b ) { $ line = rtrim ( $ b ) ; if ( strpos ( $ line , '* ' ) === 0 ) { $ line = substr ( $ line , 2 ) ; } $ line = ltrim ( $ line ) ; return $ line ; } , explode ( "\n" , $ output ) ) ; return $ branches ; }
Returns a list of the branches in the repository

@param   integer     $which      Which branches to retrieve (all, local or remote-tracking)
@return  array
Returns a list of the branches in the repository