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

ImageConverter::convert()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 10
c 0
b 0
f 0
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