src/Parse/UnifiedDiffParser.php
private function parseFile(array $fileTokenList): File
    {
        $originalName = $fileTokenList[0]->getValue();
        $newName = $fileTokenList[1]->getValue();

        $hunkList = [];
        $startIndex = 0;

        $tokenCount = count($fileTokenList);
        for ($i = 2; $i < $tokenCount; $i++) {
            // Hunk begin
            if ($this->hunkStart($fileTokenList[$i])) {
                $startIndex = $i;
            }

            // End of file, hydrate object
            if ($i === count($fileTokenList) - 1) {
                $hunkList[] = $this->parseHunk(
                    array_slice($fileTokenList, $startIndex)
                );

            // End of hunk, hydrate object
            } elseif ($this->hunkStart($fileTokenList[$i + 1])) {
                $hunkList[] = $this->parseHunk(
                    array_slice($fileTokenList, $startIndex, $i - $startIndex + 1)
                );
            }
        }

        return new File(
            $originalName,
            $newName,
            $this->getFileOperation($fileTokenList),
            $hunkList
        );
    }
private function parseFile(array $fileTokenList): File
    {
        $originalName = $fileTokenList[0]->getValue();
        $newName = $fileTokenList[1]->getValue();

        $hunkList = [];
        $startIndex = 0;

        $tokenCount = count($fileTokenList);
        for ($i = 2; $i < $tokenCount; $i++) {
            // Hunk begin
            if ($this->hunkStart($fileTokenList[$i])) {
                $startIndex = $i;
            }

            // End of file, hydrate object
            if ($i === count($fileTokenList) - 1) {
                $hunkList[] = $this->parseHunk(
                    array_slice($fileTokenList, $startIndex)
                );

            // End of hunk, hydrate object
            } elseif ($this->hunkStart($fileTokenList[$i + 1])) {
                $hunkList[] = $this->parseHunk(
                    array_slice($fileTokenList, $startIndex, $i - $startIndex + 1)
                );
            }
        }

        return new File(
            $originalName,
            $newName,
            $this->getFileOperation($fileTokenList),
            $hunkList
        );
    }
private function parseFile ( array $ fileTokenList ) : File { $ originalName = $ fileTokenList [ 0 ] -> getValue ( ) ; $ newName = $ fileTokenList [ 1 ] -> getValue ( ) ; $ hunkList = [ ] ; $ startIndex = 0 ; $ tokenCount = count ( $ fileTokenList ) ; for ( $ i = 2 ; $ i < $ tokenCount ; $ i ++ ) { // Hunk begin if ( $ this -> hunkStart ( $ fileTokenList [ $ i ] ) ) { $ startIndex = $ i ; } // End of file, hydrate object if ( $ i === count ( $ fileTokenList ) - 1 ) { $ hunkList [ ] = $ this -> parseHunk ( array_slice ( $ fileTokenList , $ startIndex ) ) ; // End of hunk, hydrate object } elseif ( $ this -> hunkStart ( $ fileTokenList [ $ i + 1 ] ) ) { $ hunkList [ ] = $ this -> parseHunk ( array_slice ( $ fileTokenList , $ startIndex , $ i - $ startIndex + 1 ) ) ; } } return new File ( $ originalName , $ newName , $ this -> getFileOperation ( $ fileTokenList ) , $ hunkList ) ; }
Process the tokens for a single file, returning a File instance on success.

@param Token[] $fileTokenList

@return File
Process the tokens for a single file returning a File instance on success .