Completed
Push — master ( 0490e0...5154b1 )
by Kevin
03:30
created

Meter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 35.48 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 11
loc 31
ccs 17
cts 17
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllowedAttributes() 0 16 1
A removeInvalidSelf() 11 11 2

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\FlowContent;
7
use Groundskeeper\Tokens\ElementTypes\OpenElement;
8
use Groundskeeper\Tokens\ElementTypes\PhrasingContent;
9
use Psr\Log\LoggerInterface;
10
11
/**
12
 * "meter" element
13
 *
14
 * https://html.spec.whatwg.org/multipage/forms.html#the-meter-element
15
 */
16
class Meter extends OpenElement implements FlowContent, PhrasingContent
17
{
18 2
    protected function getAllowedAttributes()
19
    {
20
        $meterAllowedAttributes = array(
21 2
            '/^value$/i' => Attribute::CS_STRING,
22 2
            '/^min$/i' => Attribute::CS_STRING,
23 2
            '/^max$/i' => Attribute::CS_STRING,
24 2
            '/^low$/i' => Attribute::CS_STRING,
25 2
            '/^high$/i' => Attribute::CS_STRING,
26
            '/^optimum$/i' => Attribute::CS_STRING
27 2
        );
28
29 2
        return array_merge(
30 2
            $meterAllowedAttributes,
31 2
            parent::getAllowedAttributes()
32 2
        );
33
    }
34
35 2 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 2
        $meter = new self($this->configuration, 0, 0, 'meter');
38 2
        if ($this->hasAncestor($meter)) {
39 1
            $logger->debug('Removing ' . $this . '. "Meter" element cannot contain other "meter" elements.');
40
41 1
            return true;
42
        }
43
44 2
        return false;
45
    }
46
}
47