TableRowConverter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSupportedTags() 0 3 1
A convert() 0 14 4
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
        {
22 3
            $value = str_replace("\n", ' ', $item->getValue());
23
24 3
            $null = $value === ' ' || empty($value);
25
26 3
            $null === false && array_push($children, $value);
27 1
        }
28
29 3
        return implode(' - ', $children) . "\n";
30
    }
31
32
    /**
33
     * Returns the supported HTML tags.
34
     *
35
     * @return string[]
36
     */
37 15
    public function getSupportedTags()
38
    {
39 15
        return array('tr');
40
    }
41
}
42