Code

< 40 %
40-60 %
> 60 %
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