Completed
Push — master ( 45904d...9fbe45 )
by Kevin
03:18
created

Col::doClean()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 14
ccs 0
cts 11
cp 0
rs 9.2
cc 4
eloc 7
nc 3
nop 1
crap 20
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Configuration;
6
use Groundskeeper\Tokens\Element;
7
use Groundskeeper\Tokens\ElementTypes\ClosedElement;
8
use Psr\Log\LoggerInterface;
9
10
/**
11
 * "col" element
12
 *
13
 * https://html.spec.whatwg.org/multipage/semantics.html#the-col-element
14
 */
15
class Col extends ClosedElement
16
{
17
    protected function getAllowedAttributes()
18
    {
19
        $colAllowedAttributes = array(
20
            '/^span$/i' => Element::ATTR_INT,
21
        );
22
23
        return array_merge(
24
            $colAllowedAttributes,
25
            parent::getAllowedAttributes()
26
        );
27
    }
28
29
    protected function doClean(LoggerInterface $logger)
30
    {
31
        if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) {
32
            // "colgroup" must be parent.
33
            $parent = $this->getParent();
34
            if ($parent !== null && $parent->getName() != 'colgroup') {
35
                $logger->debug('Element "col" must be a child of the "colgroup" element.');
36
37
                return false;
38
            }
39
        }
40
41
        return true;
42
    }
43
}
44