Completed
Branch master (a2aa27)
by Randy
01:27
created

VariableAnnotation::hasId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Dgame\Annotation;
4
5
/**
6
 * Class VariableAnnotation
7
 * @package Dgame\Annotation
8
 */
9
final class VariableAnnotation
10
{
11
    /**
12
     * @var AnnotationType
13
     */
14
    private $type;
15
    /**
16
     * @var string
17
     */
18
    private $id;
19
20
    /**
21
     * VariableAnnotation constructor.
22
     *
23
     * @param string $type
24
     * @param string $id
25
     */
26
    public function __construct(string $type, string $id)
27
    {
28
        $this->type = AnnotationType::parse($type);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Dgame\Annotation\AnnotationType::parse($type) of type object<self> is incompatible with the declared type object<Dgame\Annotation\AnnotationType> of property $type.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
29
        $this->id   = $id;
30
    }
31
32
    /**
33
     * @return AnnotationType
34
     */
35
    public function getType(): AnnotationType
36
    {
37
        return $this->type;
38
    }
39
40
    /**
41
     * @return bool
42
     */
43
    public function hasId(): bool
44
    {
45
        return !empty($this->id);
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getId(): string
52
    {
53
        return $this->id;
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getName(): string
60
    {
61
        return substr($this->id, 1);
62
    }
63
}