DivConverter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 25
ccs 7
cts 7
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setConfig() 0 3 1
A getSupportedTags() 0 3 1
A convert() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace League\HTMLToMarkdown\Converter;
6
7
use League\HTMLToMarkdown\Configuration;
8
use League\HTMLToMarkdown\ConfigurationAwareInterface;
9
use League\HTMLToMarkdown\ElementInterface;
10
11
class DivConverter implements ConverterInterface, ConfigurationAwareInterface
12
{
13
    /** @var Configuration */
14
    protected $config;
15
16
    public function setConfig(Configuration $config): void
17
    {
18
        $this->config = $config;
19 99
    }
20
21 99
    public function convert(ElementInterface $element): string
22 99
    {
23
        if ($this->config->getOption('strip_tags', false)) {
24
            return $element->getValue() . "\n\n";
25
        }
26
27
        return \html_entity_decode($element->getChildrenAsString());
28
    }
29 6
30
    /**
31 6
     * @return string[]
32 3
     */
33
    public function getSupportedTags(): array
34
    {
35 6
        return ['div'];
36
    }
37
}
38