Dl::removeInvalidChildren()   B
last analyzed

Complexity

Conditions 6
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 6

Importance

Changes 0
Metric Value
dl 15
loc 15
ccs 10
cts 10
cp 1
rs 8.8571
c 0
b 0
f 0
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 Psr\Log\LoggerInterface;
10
11
/**
12
 * "dl" element
13
 *
14
 * https://html.spec.whatwg.org/multipage/semantics.html#the-dl-element
15
 */
16
class Dl extends OpenElement implements FlowContent
17
{
18 3 View Code Duplication
    protected function removeInvalidChildren(LoggerInterface $logger)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    {
20
        // Only "dd", "dt", and ScriptSupporting elements allowed.
21 3
        foreach ($this->children as $child) {
22 3
            if ($child instanceof NonParticipating ||
23 3
                $child instanceof Dd ||
24 3
                $child instanceof Dt ||
25 3
                $child instanceof ScriptSupporting) {
26 3
                continue;
27
            }
28
29 1
            $logger->debug('Removing ' . $child . '. Only elements "dd", "dt", and script supporting elements allowed as children of "dl" element.');
30 1
            $this->removeChild($child);
31
        }
32 3
    }
33
}
34