protected function read($xrefContent)
    {
        // get eol markers in the first 100 bytes
        \preg_match_all("/(\r\n|\n|\r)/", \substr($xrefContent, 0, 100), $m);

        if (\count($m[0]) === 0) {
            throw new CrossReferenceException(
                'No data found in cross-reference.',
                CrossReferenceException::INVALID_DATA
            );
        }

        // count(array_count_values()) is faster then count(array_unique())
        // @see https://github.com/symfony/symfony/pull/23731
        // can be reverted for php7.2
        $differentLineEndings = \count(\array_count_values($m[0]));
        if ($differentLineEndings > 1) {
            $lines = \preg_split("/(\r\n|\n|\r)/", $xrefContent, -1, PREG_SPLIT_NO_EMPTY);
        } else {
            $lines = \explode($m[0][0], $xrefContent);
        }

        unset($differentLineEndings, $m);
        $linesCount = \count($lines);
        $start = null;
        $entryCount = 0;

        $offsets = [];

        /** @noinspection ForeachInvariantsInspection */
        for ($i = 0; $i < $linesCount; $i++) {
            $line = \trim($lines[$i]);
            if ($line) {
                $pieces = \explode(' ', $line);

                $c = \count($pieces);
                switch ($c) {
                    case 2:
                        $start = (int) $pieces[0];
                        $entryCount += (int) $pieces[1];
                        break;

                    /** @noinspection PhpMissingBreakStatementInspection */
                    case 3:
                        switch ($pieces[2]) {
                            case 'n':
                                $offsets[$start] = [(int) $pieces[0], (int) $pieces[1]];
                                $start++;
                                break 2;
                            case 'f':
                                $start++;
                                break 2;
                        }
                        // fall through if pieces doesn't match

                    default:
                        throw new CrossReferenceException(
                            \sprintf('Unexpected data in xref table (%s)', \implode(' ', $pieces)),
                            CrossReferenceException::INVALID_DATA
                        );
                }
            }
        }

        $this->offsets = $offsets;
    }