DocType   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 35
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 4 1
A toHtml() 0 4 1
A clean() 0 16 4
1
<?php
2
3
namespace Groundskeeper\Tokens;
4
5
use Groundskeeper\Configuration;
6
use Psr\Log\LoggerInterface;
7
8
class DocType extends AbstractValuedToken implements Cleanable
9
{
10 1
    public function getType() : string
11
    {
12 1
        return Token::DOCTYPE;
13
    }
14
15
    /**
16
     * Required by the Cleanable interface.
17
     */
18 4
    public function clean(LoggerInterface $logger) : bool
19
    {
20 4
        $cleanStrategyConfiguration = $this->configuration->get('clean-strategy');
21 4
        if ($cleanStrategyConfiguration === Configuration::CLEAN_STRATEGY_NONE ||
22 4
            $cleanStrategyConfiguration === Configuration::CLEAN_STRATEGY_LENIENT) {
23 4
            return true;
24
        }
25
26
        // DocType must not have any parent elements.
27 3
        $result = $this->getParent() === null;
28 3
        if (!$result) {
29 1
            $logger->debug('Removing ' . $this . '. DocType cannot be a child of any element.');
30
        }
31
32 3
        return $result;
33
    }
34
35
    /**
36
     * Required by the Token interface.
37
     */
38 5
    public function toHtml(string $prefix, string $suffix) : string
39
    {
40 5
        return $prefix . '<!DOCTYPE ' . $this->getValue() . '>' . $suffix;
41
    }
42
}
43