| Conditions | 5 |
| Paths | 7 |
| Total Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 5.583 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 18 | public function parse(InlineParserContext $inlineContext) |
|
| 16 | { |
||
| 17 | 18 | $cursor = $inlineContext->getCursor(); |
|
| 18 | 18 | $character = $cursor->getCharacter(); |
|
| 19 | 18 | if ($cursor->peek(1) != $character) { |
|
| 20 | 6 | return false; |
|
| 21 | } |
||
| 22 | 12 | $tildes = $cursor->match('/^~~+/'); |
|
| 23 | 12 | if ($tildes === '') { |
|
| 24 | false; |
||
| 25 | } |
||
| 26 | 12 | $previousState = $cursor->saveState(); |
|
| 27 | 12 | $currentPosition = $cursor->getPosition(); |
|
| 28 | 12 | while ($matchingTildes = $cursor->match('/~~+/m')) { |
|
| 29 | 12 | if ($matchingTildes === $tildes) { |
|
| 30 | 12 | $text = mb_substr($cursor->getLine(), $currentPosition, $cursor->getPosition() - $currentPosition - strlen($tildes), 'utf-8'); |
|
| 31 | 12 | $text = preg_replace('/[ \n]+/', ' ', $text); |
|
| 32 | 12 | $inlineContext->getContainer()->appendChild(new StrikeThroughElement(trim($text))); |
|
| 33 | 12 | return true; |
|
| 34 | } |
||
| 35 | } |
||
| 36 | $cursor->restoreState($previousState); |
||
| 37 | $inlineContext->getContainer()->appendChild(new Text($tildes)); |
||
| 38 | return false; |
||
| 39 | } |
||
| 40 | } |