Completed
Push — master ( 559766...559d2f )
by Kevin
03:24
created

Track::getAllowedAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 15
ccs 10
cts 10
cp 1
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Tokens\Attribute;
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 2
    protected function getAllowedAttributes()
17
    {
18
        $trackAllowedAttributes = array(
19 2
            '/^kind$/i' => Attribute::CS_STRING,
20 2
            '/^src$/i' => Attribute::URI,
21 2
            '/^srclang$/i' => Attribute::CS_STRING,
22 2
            '/^label$/i' => Attribute::CS_STRING,
23
            '/^default$/i' => Attribute::BOOL
24 2
        );
25
26 2
        return array_merge(
27 2
            $trackAllowedAttributes,
28 2
            parent::getAllowedAttributes()
29 2
        );
30
    }
31
32 2
    protected function removeInvalidSelf(LoggerInterface $logger)
33
    {
34
        // Must be child of "object" element.
35 2
        $parent = $this->getParent();
36 2
        if ($parent !== null &&
37 2
            $parent instanceof Video &&
38 2
            $parent instanceof Audio) {
39
            $logger->debug('Removing ' . $this . '. Must be a child of "video" or "audio" element.');
40
41
            return true;
42
        }
43
44 2
        return false;
45
    }
46
}
47