| Total Complexity | 5 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | class LinkConverter implements ConverterInterface |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Converts the specified element into a parsed string. |
||
| 18 | * |
||
| 19 | * @param \League\HTMLToMarkdown\ElementInterface $element |
||
| 20 | * @return string |
||
| 21 | */ |
||
| 22 | 9 | public function convert(ElementInterface $element) |
|
| 23 | { |
||
| 24 | 9 | $text = trim($element->getValue(), "\t\n\r\0\x0B"); |
|
| 25 | |||
| 26 | 9 | $href = $element->getAttribute('href'); |
|
| 27 | |||
| 28 | 9 | $markdown = $text . ' (' . $href . ')'; |
|
| 29 | |||
| 30 | 9 | $autolink = $this->isValidAutolink((string) $href); |
|
| 31 | |||
| 32 | 9 | $href === $text && $autolink && $markdown = $href; |
|
| 33 | |||
| 34 | 9 | return $markdown; |
|
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Returns the supported HTML tags. |
||
| 39 | * |
||
| 40 | * @return string[] |
||
| 41 | */ |
||
| 42 | 15 | public function getSupportedTags() |
|
| 43 | { |
||
| 44 | 15 | return array('a'); |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @param string $href |
||
| 49 | * |
||
| 50 | * @return bool |
||
| 51 | */ |
||
| 52 | 9 | private function isValidAutolink($href) |
|
| 55 | } |
||
| 56 | } |
||
| 57 |