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

TableBlockConverter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 29
ccs 9
cts 9
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 11 2
1
<?php
2
3
namespace Pilipinews\Common\Converters;
4
5
use League\HTMLToMarkdown\Converter\ConverterInterface;
6
use League\HTMLToMarkdown\ElementInterface;
7
8
class TableBlockConverter 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
        $lines = explode("\n", $element->getValue());
19
20 3
        foreach ($lines as $key => $line) {
21 3
            $lines[$key] = trim($lines[$key]);
22 2
        }
23
24 3
        $lines = array_filter($lines);
25
26 3
        return "\n" . implode("\n", (array) $lines);
27
    }
28
29
    /**
30
     * Returns the supported HTML tags.
31
     *
32
     * @return string[]
33
     */
34 12
    public function getSupportedTags()
35
    {
36 12
        return array('table');
37
    }
38
}
39