Body::getAllowedAttributes()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 20

Duplication

Lines 25
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 25
loc 25
ccs 5
cts 5
cp 1
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 20
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\OpenElement;
7
use Groundskeeper\Tokens\ElementTypes\SectioningRoot;
8
use Psr\Log\LoggerInterface;
9
10
/**
11
 * "body" element
12
 *
13
 * https://html.spec.whatwg.org/multipage/semantics.html#the-body-element
14
 */
15
class Body extends OpenElement implements SectioningRoot
16
{
17 1 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
        $bodyAllowedAttributes = array(
20 1
            '/^onafterprint$/i' => Attribute::JS,
21
            '/^onbeforeprint$/i' => Attribute::JS,
22
            '/^onbeforeunload$/i' => Attribute::JS,
23
            '/^onhashchange$/i' => Attribute::JS,
24
            '/^onlanguagechange$/i' => Attribute::JS,
25
            '/^onmessage$/i' => Attribute::JS,
26
            '/^onoffline$/i' => Attribute::JS,
27
            '/^ononline$/i' => Attribute::JS,
28
            '/^onpagehide$/i' => Attribute::JS,
29
            '/^onpageshow$/i' => Attribute::JS,
30
            '/^onpopstate$/i' => Attribute::JS,
31
            '/^onrejectionhandled$/i' => Attribute::JS,
32
            '/^onstorage$/i' => Attribute::JS,
33
            '/^onunhandledrejection$/i' => Attribute::JS,
34
            '/^onunload$/i' => Attribute::JS
35
        );
36
37 1
        return array_merge(
38 1
            $bodyAllowedAttributes,
39 1
            parent::getAllowedAttributes()
40
        );
41
    }
42
43 35 View Code Duplication
    protected function removeInvalidSelf(LoggerInterface $logger) : bool
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...
44
    {
45
        // "body" element must be a child of "html" element.
46 35
        if ($this->getParent() !== null &&
47 35
            !($this->getParent() instanceof Html)) {
48 1
            $logger->debug('Removing ' . $this . '. Must be a child of "html" element.');
49
50 1
            return true;
51
        }
52
53 34
        return false;
54
    }
55
}
56