Param   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A removeInvalidSelf() 12 12 3
A getAllowedAttributes() 12 12 1

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\Attribute;
6
use Groundskeeper\Tokens\ElementTypes\ClosedElement;
7
use Psr\Log\LoggerInterface;
8
9
/**
10
 * "param" element
11
 *
12
 * https://html.spec.whatwg.org/multipage/semantics.html#the-param-element
13
 */
14 View Code Duplication
class Param extends ClosedElement
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...
15
{
16 2
    protected function getAllowedAttributes()
17
    {
18
        $paramAllowedAttributes = array(
19 2
            '/^name$/i' => Attribute::CS_STRING,
20
            '/^value$/i' => Attribute::CS_STRING
21
        );
22
23 2
        return array_merge(
24 2
            $paramAllowedAttributes,
25 2
            parent::getAllowedAttributes()
26
        );
27
    }
28
29 2
    protected function removeInvalidSelf(LoggerInterface $logger) : bool
30
    {
31
        // Must be child of "object" element.
32 2
        $parent = $this->getParent();
33 2
        if ($parent !== null && !$parent instanceof Object) {
34 1
            $logger->debug('Removing ' . $this . '. Must be a child of "object" element.');
35
36 1
            return true;
37
        }
38
39 1
        return false;
40
    }
41
}
42