public function parseOutputLines(array $remoteDetails)
    {
        array_filter($remoteDetails);
        $name = array_shift($remoteDetails);
        $name = (is_string($name)) ? trim($name) : '';
        $name = $this->parseName($name);
        if (!$name) {
            throw new \UnexpectedValueException(sprintf('Invalid data provided for remote detail parsing'));
        }
        $this->name = $name;
        $fetchURLPattern = '/^Fetch\s+URL:\s*(.*)$/';
        $fetchURL = null;

        $pushURLPattern = '/^Push\s+URL:\s*(.*)$/';
        $pushURL = null;

        $remoteHEADPattern = '/^HEAD\s+branch:\s*(.*)$/';
        $remoteHEAD = null;

        $remoteBranchHeaderPattern = '/^Remote\s+branch(?:es)?:$/';
        $localBranchPullHeaderPattern = '/^Local\sbranch(?:es)?\sconfigured\sfor\s\'git\spull\'\:$/';
        $localRefPushHeaderPattern = '/^Local\sref(?:s)?\sconfigured\sfor\s\'git\spush\':$/';
        $groups = [
            'remoteBranches' => null,
            'localBranches'  => null,
            'localRefs'      => null,
        ];

        foreach ($remoteDetails as $lineno => $line) {
            $line = trim($line);
            $matches = [];
            if (is_null($fetchURL) && preg_match($fetchURLPattern, $line, $matches)) {
                $this->fetchURL = $fetchURL = $matches[1];
            } elseif (is_null($pushURL) && preg_match($pushURLPattern, $line, $matches)) {
                $this->pushURL = $pushURL = $matches[1];
            } elseif (is_null($remoteHEAD) && preg_match($remoteHEADPattern, $line, $matches)) {
                $this->remoteHEAD = $remoteHEAD = $matches[1];
            } elseif (is_null($groups['remoteBranches']) && preg_match($remoteBranchHeaderPattern, $line, $matches)) {
                $groups['remoteBranches'] = $lineno;
            } elseif (is_null($groups['localBranches']) && preg_match($localBranchPullHeaderPattern, $line, $matches)) {
                $groups['localBranches'] = $lineno;
            } elseif (is_null($groups['localRefs']) && preg_match($localRefPushHeaderPattern, $line, $matches)) {
                $groups['localRefs'] = $lineno;
            }
        }

        $this->setBranches($this->aggregateBranchDetails($groups, $remoteDetails));
    }
public function parseOutputLines(array $remoteDetails)
    {
        array_filter($remoteDetails);
        $name = array_shift($remoteDetails);
        $name = (is_string($name)) ? trim($name) : '';
        $name = $this->parseName($name);
        if (!$name) {
            throw new \UnexpectedValueException(sprintf('Invalid data provided for remote detail parsing'));
        }
        $this->name = $name;
        $fetchURLPattern = '/^Fetch\s+URL:\s*(.*)$/';
        $fetchURL = null;

        $pushURLPattern = '/^Push\s+URL:\s*(.*)$/';
        $pushURL = null;

        $remoteHEADPattern = '/^HEAD\s+branch:\s*(.*)$/';
        $remoteHEAD = null;

        $remoteBranchHeaderPattern = '/^Remote\s+branch(?:es)?:$/';
        $localBranchPullHeaderPattern = '/^Local\sbranch(?:es)?\sconfigured\sfor\s\'git\spull\'\:$/';
        $localRefPushHeaderPattern = '/^Local\sref(?:s)?\sconfigured\sfor\s\'git\spush\':$/';
        $groups = [
            'remoteBranches' => null,
            'localBranches'  => null,
            'localRefs'      => null,
        ];

        foreach ($remoteDetails as $lineno => $line) {
            $line = trim($line);
            $matches = [];
            if (is_null($fetchURL) && preg_match($fetchURLPattern, $line, $matches)) {
                $this->fetchURL = $fetchURL = $matches[1];
            } elseif (is_null($pushURL) && preg_match($pushURLPattern, $line, $matches)) {
                $this->pushURL = $pushURL = $matches[1];
            } elseif (is_null($remoteHEAD) && preg_match($remoteHEADPattern, $line, $matches)) {
                $this->remoteHEAD = $remoteHEAD = $matches[1];
            } elseif (is_null($groups['remoteBranches']) && preg_match($remoteBranchHeaderPattern, $line, $matches)) {
                $groups['remoteBranches'] = $lineno;
            } elseif (is_null($groups['localBranches']) && preg_match($localBranchPullHeaderPattern, $line, $matches)) {
                $groups['localBranches'] = $lineno;
            } elseif (is_null($groups['localRefs']) && preg_match($localRefPushHeaderPattern, $line, $matches)) {
                $groups['localRefs'] = $lineno;
            }
        }

        $this->setBranches($this->aggregateBranchDetails($groups, $remoteDetails));
    }
public function parseOutputLines ( array $ remoteDetails ) { array_filter ( $ remoteDetails ) ; $ name = array_shift ( $ remoteDetails ) ; $ name = ( is_string ( $ name ) ) ? trim ( $ name ) : '' ; $ name = $ this -> parseName ( $ name ) ; if ( ! $ name ) { throw new \ UnexpectedValueException ( sprintf ( 'Invalid data provided for remote detail parsing' ) ) ; } $ this -> name = $ name ; $ fetchURLPattern = '/^Fetch\s+URL:\s*(.*)$/' ; $ fetchURL = null ; $ pushURLPattern = '/^Push\s+URL:\s*(.*)$/' ; $ pushURL = null ; $ remoteHEADPattern = '/^HEAD\s+branch:\s*(.*)$/' ; $ remoteHEAD = null ; $ remoteBranchHeaderPattern = '/^Remote\s+branch(?:es)?:$/' ; $ localBranchPullHeaderPattern = '/^Local\sbranch(?:es)?\sconfigured\sfor\s\'git\spull\'\:$/' ; $ localRefPushHeaderPattern = '/^Local\sref(?:s)?\sconfigured\sfor\s\'git\spush\':$/' ; $ groups = [ 'remoteBranches' => null , 'localBranches' => null , 'localRefs' => null , ] ; foreach ( $ remoteDetails as $ lineno => $ line ) { $ line = trim ( $ line ) ; $ matches = [ ] ; if ( is_null ( $ fetchURL ) && preg_match ( $ fetchURLPattern , $ line , $ matches ) ) { $ this -> fetchURL = $ fetchURL = $ matches [ 1 ] ; } elseif ( is_null ( $ pushURL ) && preg_match ( $ pushURLPattern , $ line , $ matches ) ) { $ this -> pushURL = $ pushURL = $ matches [ 1 ] ; } elseif ( is_null ( $ remoteHEAD ) && preg_match ( $ remoteHEADPattern , $ line , $ matches ) ) { $ this -> remoteHEAD = $ remoteHEAD = $ matches [ 1 ] ; } elseif ( is_null ( $ groups [ 'remoteBranches' ] ) && preg_match ( $ remoteBranchHeaderPattern , $ line , $ matches ) ) { $ groups [ 'remoteBranches' ] = $ lineno ; } elseif ( is_null ( $ groups [ 'localBranches' ] ) && preg_match ( $ localBranchPullHeaderPattern , $ line , $ matches ) ) { $ groups [ 'localBranches' ] = $ lineno ; } elseif ( is_null ( $ groups [ 'localRefs' ] ) && preg_match ( $ localRefPushHeaderPattern , $ line , $ matches ) ) { $ groups [ 'localRefs' ] = $ lineno ; } } $ this -> setBranches ( $ this -> aggregateBranchDetails ( $ groups , $ remoteDetails ) ) ; }
parse details from remote show

@param array|string $remoteDetails Output lines for a remote show

@throws \UnexpectedValueException
parse details from remote show