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

Param   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 1 Features 1
Metric Value
wmc 5
c 1
b 1
f 1
lcom 1
cbo 3
dl 0
loc 30
ccs 0
cts 22
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllowedAttributes() 0 12 1
A doClean() 0 14 4
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