Completed
Push — master ( 62c01b...6e9edd )
by Kevin
02:26
created

DocType::clean()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 3
cts 4
cp 0.75
rs 9.6666
cc 2
eloc 4
nc 2
nop 1
crap 2.0625
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
    /**
11
     * Constructor
12
     */
13 4
    public function __construct(Configuration $configuration, $parent = null, $value = null)
14
    {
15 4
        parent::__construct(Token::DOCTYPE, $configuration, $parent, $value);
16 4
    }
17
18
    /**
19
     * Required by the Cleanable interface.
20
     */
21 2
    public function clean(LoggerInterface $logger = null)
22
    {
23 2
        if ($this->configuration->get('clean-strategy') == Configuration::CLEAN_STRATEGY_NONE) {
24
            return true;
25
        }
26
27
        // DocType must not have any parent elements.
28 2
        return $this->getParent() === null;
29
    }
30
31
    /**
32
     * Required by the Token interface.
33
     */
34 3
    public function toHtml($prefix, $suffix)
35
    {
36 3
        return $prefix . '<!DOCTYPE ' . $this->getValue() . '>' . $suffix;
37
    }
38
}
39