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

DocType   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 7
Bugs 1 Features 3
Metric Value
wmc 6
c 7
b 1
f 3
lcom 1
cbo 3
dl 0
loc 33
ccs 12
cts 12
cp 1
rs 10

3 Methods

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