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

Dfn::doClean()   B

Complexity

Conditions 6
Paths 2

Size

Total Lines 19
Code Lines 10

Duplication

Lines 19
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 19
loc 19
ccs 0
cts 16
cp 0
rs 8.8571
cc 6
eloc 10
nc 2
nop 1
crap 42
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Tokens\ElementTypes\FlowContent;
6
use Groundskeeper\Tokens\ElementTypes\InlineElement;
7
use Groundskeeper\Tokens\ElementTypes\OpenElement;
8
use Groundskeeper\Tokens\ElementTypes\PhrasingContent;
9
use Groundskeeper\Tokens\Token;
10
use Psr\Log\LoggerInterface;
11
12
/**
13
 * "dfn" element
14
 *
15
 * https://html.spec.whatwg.org/multipage/semantics.html#the-dfn-element
16
 */
17
class Dfn extends OpenElement implements FlowContent, PhrasingContent, InlineElement
18
{
19 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...
20
    {
21
        // There must be no dfn element descendants.
22
        foreach ($this->children as $child) {
23
            if ($child->getType() == Token::COMMENT) {
24
                continue;
25
            }
26
27
            if ($child->getType() == Token::ELEMENT &&
28
                $child->getName() == 'dfn') {
29
                $logger->debug('Removing ' . $child . '. Element "dfn" cannot contain "dfn" elements.');
30
                $this->removeChild($child);
31
            }
32
        }
33
    }
34
35 View Code Duplication
    protected function removeInvalidSelf(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...
36
    {
37
        $dfn = new self($this->configuration, 'dfn');
38
        if ($this->hasAncestor($dfn)) {
39
            $logger->debug('Removing ' . $child . '. Element "dfn" cannot contain "dfn" elements.');
0 ignored issues
show
Bug introduced by
The variable $child does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
40
41
            return true;
42
        }
43
44
        return false;
45
    }
46
}
47