Body::removeInvalidSelf()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 3

Importance

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