Conditions | 5 |
Paths | 6 |
Total Lines | 23 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
36 | 201 | public function parse(InlineParserContext $inlineContext) |
|
37 | { |
||
38 | 201 | $inlineContext->getCursor()->advance(); |
|
39 | |||
40 | // Check previous inline for trailing spaces |
||
41 | 201 | $spaces = 0; |
|
42 | 201 | $lastInline = $inlineContext->getContainer()->lastChild(); |
|
43 | 201 | if ($lastInline && $lastInline instanceof Text) { |
|
44 | 192 | $trimmed = rtrim($lastInline->getContent(), ' '); |
|
45 | 192 | $spaces = strlen($lastInline->getContent()) - strlen($trimmed); |
|
46 | 192 | if ($spaces) { |
|
47 | 24 | $lastInline->setContent($trimmed); |
|
48 | 16 | } |
|
49 | 128 | } |
|
50 | |||
51 | 201 | if ($spaces >= 2) { |
|
52 | 15 | $inlineContext->getContainer()->appendChild(new Newline(Newline::HARDBREAK)); |
|
53 | 10 | } else { |
|
54 | 186 | $inlineContext->getContainer()->appendChild(new Newline(Newline::SOFTBREAK)); |
|
55 | } |
||
56 | |||
57 | 201 | return true; |
|
58 | } |
||
59 | } |
||
60 |