Code Duplication    Length = 29-29 lines in 2 locations

src/Tokens/Elements/Ol.php 1 location

@@ 32-60 (lines=29) @@
29
        );
30
    }
31
32
    protected function doClean(LoggerInterface $logger)
33
    {
34
        // Only "li" and ScriptSupporting elements allowed.
35
        foreach ($this->children as $child) {
36
            if ($child->getType() == Token::COMMENT) {
37
                continue;
38
            }
39
40
            if ($child->getType() != Token::ELEMENT) {
41
                if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) {
42
                    $logger->debug('Removing ' . $child . '. Only elements "li" and script supporting elements allowed as children of "ol" element.');
43
                    $this->removeChild($child);
44
                }
45
46
                continue;
47
            }
48
49
            if ($child->getName() == 'li' || $child instanceof ScriptSupporting) {
50
                continue;
51
            }
52
53
            if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) {
54
                $logger->debug('Removing ' . $child . '. Only elements "li" and script supporting elements allowed as children of "ol" element.');
55
                $this->removeChild($child);
56
            }
57
        }
58
59
        return true;
60
    }
61
}
62

src/Tokens/Elements/Ul.php 1 location

@@ 17-45 (lines=29) @@
14
 */
15
class Ul extends OpenElement
16
{
17
    protected function doClean(LoggerInterface $logger)
18
    {
19
        // Only "li" and ScriptSupporting elements allowed.
20
        foreach ($this->children as $child) {
21
            if ($child->getType() == Token::COMMENT) {
22
                continue;
23
            }
24
25
            if ($child->getType() != Token::ELEMENT) {
26
                if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) {
27
                    $logger->debug('Removing ' . $child . '. Only elements "li" and script supporting elements allowed as children of "ul" element.');
28
                    $this->removeChild($child);
29
                }
30
31
                continue;
32
            }
33
34
            if ($child->getName() == 'li' || $child instanceof ScriptSupporting) {
35
                continue;
36
            }
37
38
            if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) {
39
                $logger->debug('Removing ' . $child . '. Only elements "li" and script supporting elements allowed as children of "ul" element.');
40
                $this->removeChild($child);
41
            }
42
        }
43
44
        return true;
45
    }
46
}
47