Completed
Push — master ( 9fbe45...817727 )
by Kevin
03:24
created

Track::doClean()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 16
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 16
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
    protected function getAllowedAttributes()
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 removeInvalidSelf(LoggerInterface $logger)
33
    {
34
        // Must be child of "object" element.
35
        $parent = $this->getParent();
36
        if ($parent !== null &&
37
            $parent->getName() !== 'video' &&
38
            $parent->getName() !== 'audio') {
39
            $logger->debug($this . ' must be a child of "video" or "audio" element.');
40
41
            return true;
42
        }
43
44
        return false;
45
    }
46
}
47