private function getChangelogEntry($filename) : ?stdClass
    {
        $contents = file($filename);
        if (false === $contents) {
            throw Exception\ChangelogFileNotFoundException::at($filename);
        }

        $data = (object) [
            'contents' => '',
            'index' => null,
            'length' => 0,
        ];

        foreach ($contents as $index => $line) {
            if (preg_match('/^## \d+\.\d+\.\d+/', $line)) {
                if ($data->index) {
                    break;
                }
                $data->contents = $line;
                $data->index = $index;
                $data->length = 1;
                continue;
            }

            if (! $data->index) {
                continue;
            }

            $data->contents .= $line;
            $data->length += 1;
        }

        return $data->index !== null ? $data : null;
    }
private function getChangelogEntry($filename) : ?stdClass
    {
        $contents = file($filename);
        if (false === $contents) {
            throw Exception\ChangelogFileNotFoundException::at($filename);
        }

        $data = (object) [
            'contents' => '',
            'index' => null,
            'length' => 0,
        ];

        foreach ($contents as $index => $line) {
            if (preg_match('/^## \d+\.\d+\.\d+/', $line)) {
                if ($data->index) {
                    break;
                }
                $data->contents = $line;
                $data->index = $index;
                $data->length = 1;
                continue;
            }

            if (! $data->index) {
                continue;
            }

            $data->contents .= $line;
            $data->length += 1;
        }

        return $data->index !== null ? $data : null;
    }
private function getChangelogEntry ( $ filename ) : ? stdClass { $ contents = file ( $ filename ) ; if ( false === $ contents ) { throw Exception \ ChangelogFileNotFoundException :: at ( $ filename ) ; } $ data = ( object ) [ 'contents' => '' , 'index' => null , 'length' => 0 , ] ; foreach ( $ contents as $ index => $ line ) { if ( preg_match ( '/^## \d+\.\d+\.\d+/' , $ line ) ) { if ( $ data -> index ) { break ; } $ data -> contents = $ line ; $ data -> index = $ index ; $ data -> length = 1 ; continue ; } if ( ! $ data -> index ) { continue ; } $ data -> contents .= $ line ; $ data -> length += 1 ; } return $ data -> index !== null ? $ data : null ; }
Retrieves the first changelog entry in the file.

If no changelog entry is found, returns null. Otherwise, returns an
anonymous object with the keys:

- index, indicating the line number where the contents began
- length, the number of lines in the contents
- contents, a string representing the changelog entry found in its entierty
Retrieves the first changelog entry in the file .