| Conditions | 4 |
| Paths | 6 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | 282 | public function parse(string $match, InlineParserContext $inlineContext): bool |
|
| 31 | { |
||
| 32 | 282 | $inlineContext->getCursor()->advanceBy(1); |
|
| 33 | |||
| 34 | // Check previous inline for trailing spaces |
||
| 35 | 282 | $spaces = 0; |
|
| 36 | 282 | $lastInline = $inlineContext->getContainer()->lastChild(); |
|
| 37 | 282 | if ($lastInline instanceof Text) { |
|
| 38 | 264 | $trimmed = \rtrim($lastInline->getLiteral(), ' '); |
|
| 39 | 264 | $spaces = \strlen($lastInline->getLiteral()) - \strlen($trimmed); |
|
| 40 | 264 | if ($spaces) { |
|
| 41 | 42 | $lastInline->setLiteral($trimmed); |
|
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | 282 | if ($spaces >= 2) { |
|
| 46 | 15 | $inlineContext->getContainer()->appendChild(new Newline(Newline::HARDBREAK)); |
|
| 47 | } else { |
||
| 48 | 267 | $inlineContext->getContainer()->appendChild(new Newline(Newline::SOFTBREAK)); |
|
| 49 | } |
||
| 50 | |||
| 51 | 282 | return true; |
|
| 52 | } |
||
| 54 |