Td   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 29
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A removeInvalidSelf() 0 12 3
A getAllowedAttributes() 0 13 1
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Tokens\Attribute;
6
use Groundskeeper\Tokens\ElementTypes\OpenElement;
7
use Groundskeeper\Tokens\ElementTypes\SectioningRoot;
8
use Psr\Log\LoggerInterface;
9
10
/**
11
 * "td" element
12
 *
13
 * https://html.spec.whatwg.org/multipage/semantics.html#the-td-element
14
 */
15
class Td extends OpenElement implements SectioningRoot
16
{
17 1
    protected function getAllowedAttributes()
18
    {
19
        $tdAllowedAttributes = array(
20 1
            '/^colspan$/i' => Attribute::INT,
21
            '/^rowspan$/i' => Attribute::INT,
22
            '/^headers$/i' => Attribute::CS_STRING
23
        );
24
25 1
        return array_merge(
26 1
            $tdAllowedAttributes,
27 1
            parent::getAllowedAttributes()
28
        );
29
    }
30
31 4
    protected function removeInvalidSelf(LoggerInterface $logger) : bool
32
    {
33
        // "tr" must be parent.
34 4
        $parent = $this->getParent();
35 4
        if ($parent !== null && !$parent instanceof Tr) {
36 1
            $logger->debug('Removing ' . $this . '. Must be a child of "tr" element.');
37
38 1
            return true;
39
        }
40
41 3
        return false;
42
    }
43
}
44