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