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

plPhpTypeDeclaration::isPresent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
/**
3
 * PHP version 7.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
class plPhpTypeDeclaration
9
{
10
    /** @var string[] All valid types for PHP 7.1 */
11
    private static $builtInTypes = [
12
        'int', 'bool', 'string', 'array', 'float', 'callable', 'iterable'
13
    ];
14
15
    /** @var string */
16
    private $name;
17
18
    public function __construct(?string $name)
19
    {
20
        $this->name = $name;
21
    }
22
23
    public function isPresent(): bool
24
    {
25
        return $this->name !== null;
26
    }
27
28
    /**
29
     * This will help when building the relationships between classes/interfaces since built-in
30
     * types are not part of a UML class diagram
31
     */
32
    public function isBuiltIn(): bool
33
    {
34
        return !empty($this->name) && in_array($this->name, self::$builtInTypes, true);
35
    }
36
37
    public function __toString()
38
    {
39
        return (string)$this->name;
40
    }
41
}
42