Dfn   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 44 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 2
dl 11
loc 25
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A removeInvalidSelf() 11 11 2
A removeInvalidChildren() 0 10 3

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\FlowContent;
6
use Groundskeeper\Tokens\ElementTypes\InlineElement;
7
use Groundskeeper\Tokens\ElementTypes\OpenElement;
8
use Groundskeeper\Tokens\ElementTypes\PhrasingContent;
9
use Psr\Log\LoggerInterface;
10
11
/**
12
 * "dfn" element
13
 *
14
 * https://html.spec.whatwg.org/multipage/semantics.html#the-dfn-element
15
 */
16
class Dfn extends OpenElement implements FlowContent, PhrasingContent, InlineElement
17
{
18 2
    protected function removeInvalidChildren(LoggerInterface $logger)
19
    {
20
        // There must be no dfn element descendants.
21 2
        foreach ($this->children as $child) {
22 2
            if ($child instanceof self) {
23 1
                $logger->debug('Removing ' . $child . '. Element "dfn" cannot contain "dfn" elements.');
24 2
                $this->removeChild($child);
25
            }
26
        }
27 2
    }
28
29 2 View Code Duplication
    protected function removeInvalidSelf(LoggerInterface $logger) : bool
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...
30
    {
31 2
        $dfn = new self($this->configuration, 0, 0, 'dfn');
32 2
        if ($this->hasAncestor($dfn)) {
33 1
            $logger->debug('Removing ' . $this . '. Element "dfn" cannot contain "dfn" elements.');
34
35 1
            return true;
36
        }
37
38 2
        return false;
39
    }
40
}
41