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

DocType::toHtml()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 2
crap 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
    /**
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