| Conditions | 7 |
| Paths | 8 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 7 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | 3 | public function convert(ElementInterface $element) |
|
| 15 | { |
||
| 16 | 3 | $href = $element->getAttribute('href'); |
|
| 17 | 3 | $title = $element->getAttribute('title'); |
|
| 18 | 3 | $text = trim($element->getValue(), "\t\n\r\0\x0B"); |
|
| 19 | |||
| 20 | 3 | if ($title !== '') { |
|
| 21 | 3 | $markdown = '[' . $text . '](' . $href . ' "' . $title . '")'; |
|
| 22 | 3 | } elseif ($href === $text && $this->isValidAutolink($href)) { |
|
| 23 | 3 | $markdown = '<' . $href . '>'; |
|
| 24 | 3 | } elseif ($href === 'mailto:' . $text && $this->isValidEmail($text)) { |
|
| 25 | 3 | $markdown = '<' . $text . '>'; |
|
| 26 | 2 | } else { |
|
| 27 | 3 | $markdown = '[' . $text . '](' . $href . ')'; |
|
| 28 | } |
||
| 29 | |||
| 30 | 3 | if (!$href) { |
|
| 31 | 3 | $markdown = html_entity_decode($element->getChildrenAsString()); |
|
| 32 | 2 | } |
|
| 33 | |||
| 34 | 3 | return $markdown; |
|
| 35 | } |
||
| 36 | |||
| 66 |