TableBlockConverter::convert()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 2
rs 10
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
        {
22 3
            $lines[$key] = trim($lines[$key]);
23 1
        }
24
25 3
        $lines = array_filter($lines);
26
27 3
        return "\n" . implode("\n", (array) $lines);
28
    }
29
30
    /**
31
     * Returns the supported HTML tags.
32
     *
33
     * @return string[]
34
     */
35 15
    public function getSupportedTags()
36
    {
37 15
        return array('table');
38
    }
39
}
40