Completed
Push — master ( 817727...d8e3ee )
by Kevin
03:58
created

Dl::removeInvalidChildren()   B

Complexity

Conditions 6
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 6

Importance

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