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