Conditions | 7 |
Paths | 4 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
29 | 2019 | public function parse(ContextInterface $context, Cursor $cursor): bool |
|
30 | { |
||
31 | 2019 | if ($cursor->isIndented()) { |
|
32 | 180 | return false; |
|
33 | } |
||
34 | |||
35 | 1962 | $c = $cursor->getCharacter(); |
|
36 | 1962 | if ($c !== ' ' && $c !== "\t" && $c !== '`' && $c !== '~') { |
|
37 | 1815 | return false; |
|
38 | } |
||
39 | |||
40 | 336 | $indent = $cursor->getIndent(); |
|
41 | 336 | $fence = $cursor->match('/^[ \t]*(?:`{3,}(?!.*`)|^~{3,})/'); |
|
42 | 336 | if ($fence === null) { |
|
43 | 231 | return false; |
|
44 | } |
||
45 | |||
46 | // fenced code block |
||
47 | 105 | $fence = \ltrim($fence, " \t"); |
|
48 | 105 | $fenceLength = \strlen($fence); |
|
49 | 105 | $context->addBlock(new FencedCode($fenceLength, $fence[0], $indent)); |
|
50 | |||
51 | 105 | return true; |
|
52 | } |
||
53 | } |
||
54 |