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