Ul   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 17
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B removeInvalidChildren() 0 14 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