1 | <?php |
||
18 | final class MarkdownInput implements MarkdownInputInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var iterable<int, string>|null |
||
22 | * |
||
23 | * @psalm-readonly-allow-private-mutation |
||
24 | */ |
||
25 | private $lines; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | * |
||
30 | * @psalm-readonly-allow-private-mutation |
||
31 | */ |
||
32 | private $content; |
||
33 | |||
34 | /** |
||
35 | * @var int|null |
||
36 | * |
||
37 | * @psalm-readonly-allow-private-mutation |
||
38 | */ |
||
39 | private $lineCount; |
||
40 | |||
41 | /** |
||
42 | * @var int |
||
43 | * |
||
44 | * @psalm-readonly |
||
45 | */ |
||
46 | private $lineOffset = 0; |
||
47 | |||
48 | 2838 | public function __construct(string $content, int $lineOffset = 0) |
|
49 | { |
||
50 | 2838 | if (! \mb_check_encoding($content, 'UTF-8')) { |
|
51 | 9 | throw new UnexpectedEncodingException('Unexpected encoding - UTF-8 or ASCII was expected'); |
|
52 | } |
||
53 | |||
54 | 2829 | $this->content = $content; |
|
55 | 2829 | $this->lineOffset = $lineOffset; |
|
56 | 2829 | } |
|
57 | |||
58 | 48 | public function getContent(): string |
|
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | 2781 | public function getLines(): iterable |
|
75 | |||
76 | 3 | public function getLineCount(): int |
|
84 | |||
85 | 36 | public function getLineOffset(): int |
|
89 | |||
90 | 2784 | private function splitLinesIfNeeded(): void |
|
112 | } |
||
113 |