Completed
Push — master ( 9fbe45...817727 )
by Kevin
03:24
created

Dl::doClean()   D

Complexity

Conditions 9
Paths 7

Size

Total Lines 31
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 9

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 31
ccs 20
cts 20
cp 1
rs 4.909
cc 9
eloc 17
nc 7
nop 1
crap 9
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\Token;
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 View Code Duplication
class Dl extends OpenElement implements FlowContent
0 ignored issues
show
Duplication introduced by
This class 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...
17
{
18 3
    protected function removeInvalidChildren(LoggerInterface $logger)
19
    {
20
        // Only "dd", "dt", and ScriptSupporting elements allowed.
21 3
        foreach ($this->children as $child) {
22 3
            if ($child->getType() == Token::COMMENT) {
23 1
                continue;
24
            }
25
26 3
            if ($child->getType() != Token::ELEMENT) {
27 1
                $logger->debug('Removing ' . $child . '. Only elements "dd", "dt", and script supporting elements allowed as children of "dl" element.');
28 1
                $this->removeChild($child);
29
30 1
                continue;
31
            }
32
33 3
            if ($child->getName() == 'dd' ||
34 3
                $child->getName() == 'dt' ||
35 3
                $child instanceof ScriptSupporting) {
36 3
                continue;
37
            }
38
39 1
            $logger->debug('Removing ' . $child . '. Only elements "dd", "dt", and script supporting elements allowed as children of "dl" element.');
40 1
            $this->removeChild($child);
41 3
        }
42 3
    }
43
}
44