Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
30 | 33 | public function parse(string $match, InlineParserContext $inlineContext): bool |
|
31 | { |
||
32 | // The last character cannot be - or _ |
||
33 | 33 | if (\in_array(\substr($match, -1), ['-', '_'], true)) { |
|
34 | 9 | return false; |
|
35 | } |
||
36 | |||
37 | // Does the URL end with punctuation that should be stripped? |
||
38 | 27 | if (\substr($match, -1) === '.') { |
|
39 | 6 | $match = \substr($match, 0, -1); |
|
40 | } |
||
41 | |||
42 | 27 | $inlineContext->getCursor()->advanceBy(\strlen($match)); |
|
43 | 27 | $inlineContext->getContainer()->appendChild(new Link('mailto:' . $match, $match)); |
|
44 | |||
45 | 27 | return true; |
|
46 | } |
||
48 |