Completed
Push — master ( 7da979...51616b )
by Colin
07:35 queued 05:03
created

ImageConverter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 29
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A convert() 0 13 2
A getSupportedTags() 0 4 1
1
<?php
2
3
namespace League\HTMLToMarkdown\Converter;
4
5
use League\HTMLToMarkdown\ElementInterface;
6
7
class ImageConverter implements ConverterInterface
8
{
9
    /**
10
     * @param ElementInterface $element
11
     *
12
     * @return string
13
     */
14 6
    public function convert(ElementInterface $element)
15
    {
16 6
        $src = $element->getAttribute('src');
17 6
        $alt = $element->getAttribute('alt');
18 6
        $title = $element->getAttribute('title');
19
20 6
        if ($title !== '') {
21
            // No newlines added. <img> should be in a block-level element.
22 6
            return '![' . $alt . '](' . $src . ' "' . $title . '")';
23
        }
24
25
        return '![' . $alt . '](' . $src . ')';
26
    }
27
28
    /**
29
     * @return string[]
30
     */
31 81
    public function getSupportedTags()
32
    {
33 81
        return array('img');
34
    }
35
}
36