| Conditions | 5 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 5 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | 1704 | public function parse(ContextInterface $context, Cursor $cursor) |
|
| 32 | { |
||
| 33 | 1704 | if ($cursor->isIndented()) { |
|
| 34 | 177 | return false; |
|
| 35 | } |
||
| 36 | |||
| 37 | 1650 | if (!($context->getContainer() instanceof Paragraph)) { |
|
| 38 | 1650 | return false; |
|
| 39 | } |
||
| 40 | |||
| 41 | 303 | $match = RegexHelper::matchAll('/^(?:=+|-+) *$/', $cursor->getLine(), $cursor->getFirstNonSpacePosition()); |
|
| 42 | 303 | if ($match === null) { |
|
| 43 | 261 | return false; |
|
| 44 | } |
||
| 45 | |||
| 46 | 48 | $level = $match[0][0] === '=' ? 1 : 2; |
|
| 47 | 48 | $strings = $context->getContainer()->getStrings(); |
|
| 48 | |||
| 49 | 48 | $context->replaceContainerBlock(new Heading($level, $strings)); |
|
| 50 | |||
| 51 | 48 | return true; |
|
| 52 | } |
||
| 53 | } |
||
| 54 |