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

plPhpVariable   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
dl 0
loc 30
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A hasType() 0 3 1
A __construct() 0 4 1
A isBuiltIn() 0 3 1
A __toString() 0 6 2
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