Completed
Push — master ( b66e97...9d450b )
by Kevin
02:16
created

DocType::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Groundskeeper\Tokens;
4
5
use Groundskeeper\Configuration;
6
7
class DocType extends AbstractValuedToken
8
{
9
    /**
10
     * Constructor
11
     */
12 2
    public function __construct(Token $parent = null, $value = null)
13
    {
14 2
        parent::__construct(Token::DOCTYPE, $parent, $value);
15 2
    }
16
17 2
    public function validate(Configuration $configuration)
18
    {
19 2
        parent::validate($configuration);
20
21 2
        if ($this->isValid === true) {
22 2
            $this->isValid = $this->getParent() === null;
0 ignored issues
show
Documentation Bug introduced by
The property $isValid was declared of type integer, but $this->getParent() === null is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
23 2
        }
24 2
    }
25
26 2
    public function toString(Configuration $configuration, $prefix = '', $suffix = '')
27
    {
28 2
        if (!$this->isValid) {
29
            return '';
30
        }
31
32 2
        return $prefix . '<!DOCTYPE ' . $this->getValue() . '>' . $suffix;
33
    }
34
}
35