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

Track   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 88.89%

Importance

Changes 4
Bugs 2 Features 1
Metric Value
wmc 5
c 4
b 2
f 1
lcom 0
cbo 2
dl 0
loc 33
ccs 16
cts 18
cp 0.8889
rs 10

2 Methods

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