Img::getAllowedAttributes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 15

Duplication

Lines 20
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 20
loc 20
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 15
nc 1
nop 0
crap 1
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