Conditions | 7 |
Paths | 4 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
21 | 1899 | public function tryStart(Cursor $cursor, MarkdownParserStateInterface $parserState): ?BlockStart |
|
22 | { |
||
23 | 1899 | if ($cursor->isIndented()) { |
|
24 | 183 | return BlockStart::none(); |
|
25 | } |
||
26 | |||
27 | 1800 | $c = $cursor->getCharacter(); |
|
28 | 1800 | if ($c !== ' ' && $c !== "\t" && $c !== '`' && $c !== '~') { |
|
29 | 1575 | return BlockStart::none(); |
|
30 | } |
||
31 | |||
32 | 294 | $indent = $cursor->getIndent(); |
|
33 | 294 | $fence = $cursor->match('/^[ \t]*(?:`{3,}(?!.*`)|^~{3,})/'); |
|
34 | 294 | if ($fence === null) { |
|
35 | 189 | return BlockStart::none(); |
|
36 | } |
||
37 | |||
38 | // fenced code block |
||
39 | 105 | $fence = \ltrim($fence, " \t"); |
|
40 | 105 | $fenceLength = \strlen($fence); |
|
41 | |||
42 | 105 | return BlockStart::of(new FencedCodeParser($fenceLength, $fence[0], $indent))->at($cursor); |
|
43 | } |
||
44 | } |
||
45 |