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

Th::getAllowedAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 15
loc 15
ccs 10
cts 10
cp 1
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Configuration;
6
use Groundskeeper\Tokens\Element;
7
use Groundskeeper\Tokens\ElementTypes\OpenElement;
8
use Psr\Log\LoggerInterface;
9
10
/**
11
 * "th" element
12
 *
13
 * https://html.spec.whatwg.org/multipage/semantics.html#the-th-element
14
 */
15 View Code Duplication
class Th extends OpenElement
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17 1
    protected function getAllowedAttributes()
18
    {
19
        $thAllowedAttributes = array(
20 1
            '/^colspan$/i' => Element::ATTR_INT,
21 1
            '/^rowspan$/i' => Element::ATTR_INT,
22 1
            '/^headers$/i' => Element::ATTR_CS_STRING,
23 1
            '/^scope$/i' => Element::ATTR_CS_STRING,
24
            '/^abbr$/i' => Element::ATTR_CS_STRING
25 1
        );
26
27 1
        return array_merge(
28 1
            $thAllowedAttributes,
29 1
            parent::getAllowedAttributes()
30 1
        );
31
    }
32
33 2
    protected function doClean(LoggerInterface $logger)
34
    {
35 2
        if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) {
36
            // "tr" must be parent.
37 2
            $parent = $this->getParent();
38 2
            if ($parent !== null &&
39 2
                $parent->getName() != 'tr') {
40 1
                $logger->debug('Element "th" must be a child of "tr" element.');
41
42 1
                return false;
43
            }
44 1
        }
45
46 2
        return true;
47
    }
48
}
49