Completed
Push — master ( 91ab9a...64950e )
by Kevin
04:15
created

Label   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 35.48 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 11
loc 31
ccs 12
cts 14
cp 0.8571
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllowedAttributes() 0 11 1
A removeInvalidSelf() 11 11 2
A isInteractiveContent() 0 4 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\Element;
7
use Groundskeeper\Tokens\ElementTypes\FlowContent;
8
use Groundskeeper\Tokens\ElementTypes\InteractiveContent;
9
use Groundskeeper\Tokens\ElementTypes\OpenElement;
10
use Groundskeeper\Tokens\ElementTypes\PhrasingContent;
11
use Psr\Log\LoggerInterface;
12
13
/**
14
 * "label" element
15
 *
16
 * https://html.spec.whatwg.org/multipage/semantics.html#the-label-element
17
 */
18
class Label extends OpenElement implements FlowContent, InteractiveContent, PhrasingContent
19
{
20 2
    protected function getAllowedAttributes()
21
    {
22
        $labelAllowedAttributes = array(
23
            '/^for$/i' => Attribute::CS_STRING
24 2
        );
25
26 2
        return array_merge(
27 2
            $labelAllowedAttributes,
28 2
            parent::getAllowedAttributes()
29 2
        );
30
    }
31
32 5 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...
33
    {
34 5
        $label = new self($this->configuration, 'label');
35 5
        if ($this->hasAncestor($label)) {
36 1
            $logger->debug('Removing ' . $this . '. Cannot be have "label" element ancestor.');
37
38 1
            return true;
39
        }
40
41 5
        return false;
42
    }
43
44
    public function isInteractiveContent()
45
    {
46
        return true;
47
    }
48
}
49