Ol   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 31
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllowedAttributes() 0 13 1
B removeInvalidChildren() 0 14 5
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Tokens\Attribute;
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 Psr\Log\LoggerInterface;
11
12
/**
13
 * "ol" element
14
 *
15
 * https://html.spec.whatwg.org/multipage/semantics.html#the-ol-element
16
 */
17
class Ol extends OpenElement implements FlowContent
18
{
19 1
    protected function getAllowedAttributes()
20
    {
21
        $olAllowedAttributes = array(
22 1
            '/^reversed$/i' => Attribute::BOOL,
23
            '/^start$/i' => Attribute::INT,
24
            '/^type$/i' => Attribute::CS_STRING
25
        );
26
27 1
        return array_merge(
28 1
            $olAllowedAttributes,
29 1
            parent::getAllowedAttributes()
30
        );
31
    }
32
33 2
    protected function removeInvalidChildren(LoggerInterface $logger)
34
    {
35
        // Only "li" and ScriptSupporting elements allowed.
36 2
        foreach ($this->children as $child) {
37 2
            if ($child instanceof NonParticipating ||
38 2
                $child instanceof Li ||
39 2
                $child instanceof ScriptSupporting) {
40 2
                continue;
41
            }
42
43 1
            $logger->debug('Removing ' . $child . '. Only elements "li" and script supporting elements allowed as children of "ol" element.');
44 1
            $this->removeChild($child);
45
        }
46 2
    }
47
}
48