Conditions | 5 |
Paths | 4 |
Total Lines | 28 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 5.0042 |
Changes | 0 |
1 | <?php |
||
37 | 93 | public function parse(InlineParserContext $inlineContext) |
|
38 | { |
||
39 | 93 | $cursor = $inlineContext->getCursor(); |
|
40 | 93 | if ($cursor->getCharacter() !== '\\') { |
|
41 | return false; |
||
42 | } |
||
43 | |||
44 | 93 | $nextChar = $cursor->peek(); |
|
45 | |||
46 | 93 | if ($nextChar === "\n") { |
|
47 | 12 | $cursor->advanceBy(2); |
|
48 | 12 | $inlineContext->getContainer()->appendChild(new Newline(Newline::HARDBREAK)); |
|
49 | |||
50 | 12 | return true; |
|
51 | 81 | } elseif ($nextChar !== null && |
|
52 | 75 | preg_match('/' . RegexHelper::REGEX_ESCAPABLE . '/', $nextChar) |
|
53 | 54 | ) { |
|
54 | 69 | $cursor->advanceBy(2); |
|
55 | 69 | $inlineContext->getContainer()->appendChild(new Text($nextChar)); |
|
56 | |||
57 | 69 | return true; |
|
58 | } |
||
59 | |||
60 | 12 | $cursor->advance(); |
|
61 | 12 | $inlineContext->getContainer()->appendChild(new Text('\\')); |
|
62 | |||
63 | 12 | return true; |
|
64 | } |
||
65 | } |
||
66 |