Dt   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 30
Duplicated Lines 43.33 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A removeInvalidSelf() 0 13 3
B removeInvalidChildren() 13 13 6

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Tokens\ElementTypes\HeadingContent;
6
use Groundskeeper\Tokens\ElementTypes\OpenElement;
7
use Groundskeeper\Tokens\ElementTypes\SectioningContent;
8
use Psr\Log\LoggerInterface;
9
10
/**
11
 * "dt" element
12
 *
13
 * https://html.spec.whatwg.org/multipage/semantics.html#the-dt-element
14
 */
15
class Dt extends OpenElement
16
{
17 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...
18
    {
19
        // No "header", "footer", sectioning content, or heading content descendants.
20 3
        foreach ($this->children as $child) {
21 3
            if ($child instanceof Header ||
22 3
                $child instanceof Footer ||
23 3
                $child instanceof SectioningContent ||
24 3
                $child instanceof HeadingContent) {
25 1
                $logger->debug('Removing ' . $child . '. No "header", "footer", and sectioning content, or heading content elements allowed as children of "dt" element.');
26 3
                $this->removeChild($child);
27
            }
28
        }
29 3
    }
30
31 4
    protected function removeInvalidSelf(LoggerInterface $logger) : bool
32
    {
33
        // Must be child of "dl" element.
34 4
        $parent = $this->getParent();
35 4
        if ($parent !== null &&
36 4
            !$parent instanceof Dl) {
37 1
            $logger->debug('Removing ' . $this . '. Must be a child of a "dl" element.');
38
39 1
            return true;
40
        }
41
42 3
        return false;
43
    }
44
}
45