Ul::removeInvalidChildren()   B
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 8
nc 3
nop 1
crap 5
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Tokens\ElementTypes\FlowContent;
6
use Groundskeeper\Tokens\ElementTypes\OpenElement;
7
use Groundskeeper\Tokens\ElementTypes\ScriptSupporting;
8
use Groundskeeper\Tokens\NonParticipating;
9
use Psr\Log\LoggerInterface;
10
11
/**
12
 * "ul" element
13
 *
14
 * https://html.spec.whatwg.org/multipage/semantics.html#the-ul-element
15
 */
16
class Ul extends OpenElement implements FlowContent
17
{
18 2
    protected function removeInvalidChildren(LoggerInterface $logger)
19
    {
20
        // Only "li" and ScriptSupporting elements allowed.
21 2
        foreach ($this->children as $child) {
22 2
            if ($child instanceof NonParticipating ||
23 2
                $child instanceof Li ||
24 2
                $child instanceof ScriptSupporting) {
25 2
                continue;
26
            }
27
28 1
            $logger->debug('Removing ' . $child . '. Only elements "li" and script supporting elements allowed as children of "ul" element.');
29 1
            $this->removeChild($child);
30
        }
31 2
    }
32
}
33