Passed
Push — master ( 87f3db...2efc06 )
by Rougin
02:07
created

TableRowConverter   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 20%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 31
ccs 2
cts 10
cp 0.2
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSupportedTags() 0 3 1
A convert() 0 13 5
1
<?php
2
3
namespace Pilipinews\Common\Converters;
4
5
use League\HTMLToMarkdown\Converter\ConverterInterface;
6
use League\HTMLToMarkdown\ElementInterface;
7
8
class TableRowConverter implements ConverterInterface
9
{
10
    /**
11
     * Converts the specified element into a parsed string.
12
     *
13
     * @param  \League\HTMLToMarkdown\ElementInterface $element
14
     * @return string
15
     */
16
    public function convert(ElementInterface $element)
17
    {
18
        $children = array();
19
20
        foreach ($element->getChildren() as $item) {
21
            $value = str_replace("\n", ' ', $item->getValue());
22
23
            if ($value == ' ' || empty($value) || $value == null) continue;
24
25
            array_push($children, trim($value));
26
        }
27
28
        return implode(' - ', $children) . "\n";
29
    }
30
31
    /**
32
     * Returns the supported HTML tags.
33
     *
34
     * @return string[]
35
     */
36 12
    public function getSupportedTags()
37
    {
38 12
        return array('tr');
39
    }
40
}
41