Completed
Push — master ( 817727...d8e3ee )
by Kevin
03:58
created

Table   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 2 Features 1
Metric Value
wmc 10
c 4
b 2
f 1
lcom 1
cbo 2
dl 0
loc 24
ccs 15
cts 15
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B removeInvalidChildren() 0 18 10
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Configuration;
6
use Groundskeeper\Tokens\ElementTypes\FlowContent;
7
use Groundskeeper\Tokens\ElementTypes\OpenElement;
8
use Groundskeeper\Tokens\ElementTypes\ScriptSupporting;
9
use Groundskeeper\Tokens\NonParticipating;
10
use Groundskeeper\Tokens\Token;
11
use Psr\Log\LoggerInterface;
12
13
/**
14
 * "table" element
15
 *
16
 * https://html.spec.whatwg.org/multipage/semantics.html#the-table-element
17
 */
18
class Table extends OpenElement implements FlowContent
19
{
20
    /**
21
     * @todo Deal with validation of the order of child elements.
22
     */
23 5
    protected function removeInvalidChildren(LoggerInterface $logger)
24
    {
25 5
        foreach ($this->children as $child) {
26 5
            if ($child instanceof NonParticipating ||
27 5
                $child instanceof Caption ||
28 5
                $child instanceof Colgroup ||
29 5
                $child instanceof Thead ||
30 5
                $child instanceof Tbody ||
31 5
                $child instanceof Tr ||
32 4
                $child instanceof Tfoot ||
33 5
                $child instanceof ScriptSupporting) {
34 5
                continue;
35
            }
36
37 1
            $logger->debug('Removing ' . $child . '. Only "caption", "colgroup", "thead", "tbody", "tr", "tfoot", and script supporting elements allowed as children of "table" element.');
38 1
            $this->removeChild($child);
39 5
        }
40 5
    }
41
}
42