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

DocType   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 92.31%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 5
c 2
b 0
f 2
lcom 1
cbo 1
dl 0
loc 28
ccs 12
cts 13
cp 0.9231
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A validate() 0 8 2
A toString() 0 8 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