Passed
Push — master ( a95238...9047ed )
by Rougin
02:29
created

TableRowConverter::convert()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 6
nc 5
nop 1
dl 0
loc 13
ccs 8
cts 8
cp 1
crap 4
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
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 3
    public function convert(ElementInterface $element)
17
    {
18 3
        $children = array();
19
20 3
        foreach ($element->getChildren() as $item) {
21 3
            $value = str_replace("\n", ' ', $item->getValue());
22
23 3
            $null = $value === ' ' || empty($value);
24
25 3
            $null === false && array_push($children, $value);
26 2
        }
27
28 3
        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