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

Track::doClean()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

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