src/Viserio/Component/Parser/Parser/PoParser.php
private static function extractMultiLines(
        ?string $state,
        array $entry,
        string $line,
        string $key,
        int $i
    ): array {
        $addEntry = static function (array $entry, ?string $state, string $line): array {
            if (! isset($entry[$state])) {
                throw new ParseException([
                    'message' => \sprintf('Parse error! Missing state: [%s].', $state),
                ]);
            }

            // Convert it to array
            if (\is_string($entry[$state])) {
                $entry[$state] = [$entry[$state]];
            }

            $entry[$state][] = self::convertString($line);

            return $entry;
        };

        switch ($state) {
            case 'msgctxt':
            case 'msgid':
            case 'msgid_plural':
                $entry = $addEntry($entry, $state, $line);

                break;
            case 'msgstr':
                $entry['msgstr'][] = self::convertString($line);

                break;

            default:
                if ($state !== null && (\mb_strpos($state, 'msgstr[') !== false)) {
                    $entry = $addEntry($entry, $state, $line);
                } elseif ($key[0] === '#' && $key[1] !== ' ') {
                    throw new ParseException([
                        'message' => \sprintf(
                            'Parse error! Comments must have a space after them on line: [%s].',
                            $i
                        ),
                    ]);
                } else {
                    throw new ParseException([
                        'message' => \sprintf(
                            'Parse error! Unknown key [%s] on line: [%s].',
                            $key,
                            $i
                        ),
                        'line' => $i,
                    ]);
                }
        }

        return $entry;
    }
private static function extractMultiLines(
        ?string $state,
        array $entry,
        string $line,
        string $key,
        int $i
    ): array {
        $addEntry = static function (array $entry, ?string $state, string $line): array {
            if (! isset($entry[$state])) {
                throw new ParseException([
                    'message' => \sprintf('Parse error! Missing state: [%s].', $state),
                ]);
            }

            // Convert it to array
            if (\is_string($entry[$state])) {
                $entry[$state] = [$entry[$state]];
            }

            $entry[$state][] = self::convertString($line);

            return $entry;
        };

        switch ($state) {
            case 'msgctxt':
            case 'msgid':
            case 'msgid_plural':
                $entry = $addEntry($entry, $state, $line);

                break;
            case 'msgstr':
                $entry['msgstr'][] = self::convertString($line);

                break;

            default:
                if ($state !== null && (\mb_strpos($state, 'msgstr[') !== false)) {
                    $entry = $addEntry($entry, $state, $line);
                } elseif ($key[0] === '#' && $key[1] !== ' ') {
                    throw new ParseException([
                        'message' => \sprintf(
                            'Parse error! Comments must have a space after them on line: [%s].',
                            $i
                        ),
                    ]);
                } else {
                    throw new ParseException([
                        'message' => \sprintf(
                            'Parse error! Unknown key [%s] on line: [%s].',
                            $key,
                            $i
                        ),
                        'line' => $i,
                    ]);
                }
        }

        return $entry;
    }
Export multi-lines from given line.
Throws a exception if state is not found or broken comment is given.

@param null|string $state
@param array       $entry
@param string      $line
@param string      $key
@param int         $i

@throws \Viserio\Component\Contract\Parser\Exception\ParseException

@return array