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