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

Meter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 35.48 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 11
loc 31
ccs 0
cts 24
cp 0
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
10
/**
11
 * "meter" element
12
 *
13
 * https://html.spec.whatwg.org/multipage/forms.html#the-meter-element
14
 */
15
class Meter extends OpenElement implements FlowContent, PhrasingContent
16
{
17
    protected function getAllowedAttributes()
18
    {
19
        $meterAllowedAttributes = array(
20
            '/^value$/i' => Attribute::CS_STRING,
21
            '/^min$/i' => Attribute::CS_STRING,
22
            '/^max$/i' => Attribute::CS_STRING,
23
            '/^low$/i' => Attribute::CS_STRING,
24
            '/^high$/i' => Attribute::CS_STRING,
25
            '/^optimum$/i' => Attribute::CS_STRING
26
        );
27
28
        return array_merge(
29
            $meterAllowedAttributes,
30
            parent::getAllowedAttributes()
31
        );
32
    }
33
34 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...
35
    {
36
        $meter = new self($this->configuration, 'meter');
37
        if ($this->hasAncestor($meter)) {
38
            $logger->debug('Removing ' . $this . '. "Meter" element cannot contain other "meter" elements.');
39
40
            return true;
41
        }
42
43
        return false;
44
    }
45
}
46