BlockquoteConverter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 0
loc 32
ccs 13
cts 13
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A convert() 0 22 3
A getSupportedTags() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace League\HTMLToMarkdown\Converter;
6
7
use League\HTMLToMarkdown\ElementInterface;
8
9
class BlockquoteConverter implements ConverterInterface
10
{
11
    public function convert(ElementInterface $element): string
12
    {
13
        // Contents should have already been converted to Markdown by this point,
14 6
        // so we just need to add '>' symbols to each line.
15
16
        $markdown = '';
17
18
        $quoteContent = \trim($element->getValue());
19 6
20
        $lines = \preg_split('/\r\n|\r|\n/', $quoteContent);
21 6
        \assert(\is_array($lines));
22
23 6
        $totalLines = \count($lines);
24
25 6
        foreach ($lines as $i => $line) {
26
            $markdown .= '> ' . $line . "\n";
27 6
            if ($i + 1 === $totalLines) {
28 6
                $markdown .= "\n";
29 6
            }
30 6
        }
31 4
32 4
        return $markdown;
33
    }
34 6
35
    /**
36
     * @return string[]
37
     */
38
    public function getSupportedTags(): array
39
    {
40 99
        return ['blockquote'];
41
    }
42
}
43