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