Passed
Push — master ( 7a3b2e...8bbdd5 )
by Rougin
02:35
created

ImageConverter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 26
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSupportedTags() 0 3 1
A convert() 0 8 2
1
<?php
2
3
namespace Pilipinews\Common\Converters;
4
5
use League\HTMLToMarkdown\Converter\ConverterInterface;
6
use League\HTMLToMarkdown\ElementInterface;
7
8
/**
9
 * Image Converter
10
 *
11
 * @package Pilipinews
12
 * @author  Rougin Gutib <[email protected]>
13
 */
14
class ImageConverter 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 3
    public function convert(ElementInterface $element)
23
    {
24 3
        if (! $source = $element->getAttribute('src'))
25 2
        {
26 3
            return '';
27
        }
28
29 3
        return "\n\nPHOTO: " . $source . "\n\n";
30
    }
31
32
    /**
33
     * Returns the supported HTML tags.
34
     *
35
     * @return string[]
36
     */
37 12
    public function getSupportedTags()
38
    {
39 12
        return array('img');
40
    }
41
}
42