Img   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 86.96 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 20
loc 23
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAllowedAttributes() 20 20 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
8
/**
9
 * "img" element
10
 *
11
 * https://html.spec.whatwg.org/multipage/semantics.html#the-img-element
12
 *
13
 * @todo Finish attributes and doClean.
14
 */
15
class Img extends ClosedElement
16
{
17 9 View Code Duplication
    protected function getAllowedAttributes()
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...
18
    {
19
        $imgAllowedAttributes = array(
20 9
            '/^alt$/i' => Attribute::CS_STRING,
21
            '/^src$/i' => Attribute::URI,
22
            '/^srcset$/i' => Attribute::CS_STRING,
23
            '/^sizes$/i' => Attribute::CS_STRING,
24
            '/^crossorigin$/i' => Attribute::CS_STRING,
25
            '/^usemap$/i' => Attribute::CS_STRING,
26
            '/^ismap$/i' => Attribute::CS_STRING,
27
            '/^width$/i' => Attribute::INT,
28
            '/^height$/i' => Attribute::INT,
29
            '/^referrerpolicy$/i' => Attribute::CS_STRING
30
        );
31
32 9
        return array_merge(
33 9
            $imgAllowedAttributes,
34 9
            parent::getAllowedAttributes()
35
        );
36
    }
37
}
38