Completed
Push — master ( e0ac7a...8eddfc )
by Kevin
03:21
created

Param::doClean()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 14
ccs 0
cts 11
cp 0
rs 9.2
cc 4
eloc 7
nc 3
nop 1
crap 20
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Configuration;
6
use Groundskeeper\Tokens\Element;
7
use Groundskeeper\Tokens\ElementTypes\ClosedElement;
8
use Psr\Log\LoggerInterface;
9
10
/**
11
 * "param" element
12
 *
13
 * https://html.spec.whatwg.org/multipage/semantics.html#the-param-element
14
 */
15
class Param extends ClosedElement
16
{
17
    protected function getAllowedAttributes()
18
    {
19
        $paramAllowedAttributes = array(
20
            '/^name$/i' => Element::ATTR_CS_STRING,
21
            '/^value$/i' => Element::ATTR_CS_STRING
22
        );
23
24
        return array_merge(
25
            $paramAllowedAttributes,
26
            parent::getAllowedAttributes()
27
        );
28
    }
29
30
    protected function doClean(LoggerInterface $logger)
31
    {
32
        if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) {
33
            // Must be child of "object" element.
34
            $parent = $this->getParent();
35
            if ($parent !== null && $parent->getName() !== 'object') {
36
                $logger->debug('Element "param" must be a child of "object" element.');
37
38
                return false;
39
            }
40
        }
41
42
        return true;
43
    }
44
}
45