Conditions | 8 |
Paths | 10 |
Total Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 8.0747 |
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 | 1 | } else { |
|
27 | 3 | if (stristr($href, ' ')) { |
|
28 | $href = '<'.$href.'>'; |
||
29 | } |
||
30 | 3 | $markdown = '[' . $text . '](' . $href . ')'; |
|
31 | } |
||
32 | |||
33 | 3 | if (!$href) { |
|
34 | 3 | $markdown = html_entity_decode($element->getChildrenAsString()); |
|
35 | 1 | } |
|
36 | |||
37 | 3 | return $markdown; |
|
38 | } |
||
39 | |||
69 |