Total Complexity | 6 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | final class FootnoteRefParser implements InlineParserInterface |
||
23 | { |
||
24 | /** |
||
25 | * {@inheritDoc} |
||
26 | */ |
||
27 | 90 | public function getCharacters(): array |
|
28 | { |
||
29 | 90 | return ['[']; |
|
30 | } |
||
31 | |||
32 | 75 | public function parse(InlineParserContext $inlineContext): bool |
|
33 | { |
||
34 | 75 | $container = $inlineContext->getContainer(); |
|
35 | 75 | $cursor = $inlineContext->getCursor(); |
|
36 | 75 | $nextChar = $cursor->peek(); |
|
37 | 75 | if ($nextChar !== '^') { |
|
38 | 18 | return false; |
|
39 | } |
||
40 | |||
41 | 63 | $state = $cursor->saveState(); |
|
42 | |||
43 | 63 | $m = $cursor->match('#\[\^([^\s\]]+)\]#'); |
|
44 | 63 | if ($m !== null) { |
|
45 | 60 | if (\preg_match('#\[\^([^\s\]]+)\]#', $m, $matches) > 0) { |
|
46 | 60 | $container->appendChild(new FootnoteRef($this->createReference($matches[1]))); |
|
47 | |||
48 | 60 | return true; |
|
49 | } |
||
50 | } |
||
51 | |||
52 | 3 | $cursor->restoreState($state); |
|
53 | |||
54 | 3 | return false; |
|
55 | } |
||
56 | |||
57 | 60 | private function createReference(string $label): Reference |
|
60 | } |
||
61 | } |
||
62 |