Test Failed
Push — graphviz-refactoring ( 3f1b14 )
by Luis
02:18
created

plPhpVariable::__toString()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 1
nop 0
1
<?php
2
3
class plPhpVariable
4
{
5
    /** @var string */
6
    public $name;
7
8
    /** @var plPhpTypeDeclaration */
9
    public $type;
10
11
    public function __construct(string $name, string $type = null)
12
    {
13
        $this->name = $name;
14
        $this->type = new plPhpTypeDeclaration($type);
15
    }
16
17
    public function hasType(): bool
18
    {
19
        return $this->type->isPresent();
20
    }
21
22
    public function isBuiltIn(): bool
23
    {
24
        return $this->type->isBuiltIn();
25
    }
26
27
    public function __toString()
28
    {
29
        return sprintf(
30
            '%s%s',
31
            $this->type->isPresent() ? "{$this->type} " : '',
32
            $this->name
33
        );
34
    }
35
}
36