VariableAnnotation   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 57
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getType() 0 4 1
A hasId() 0 4 1
A getId() 0 4 1
A getName() 0 4 1
1
<?php
2
3
namespace Dgame\Annotation;
4
5
use Exception;
6
7
/**
8
 * Class VariableAnnotation
9
 * @package Dgame\Annotation
10
 */
11
final class VariableAnnotation
12
{
13
    /**
14
     * @var AnnotationType
15
     */
16
    private $type;
17
    /**
18
     * @var string
19
     */
20
    private $id;
21
22
    /**
23
     * VariableAnnotation constructor.
24
     *
25
     * @param string $type
26
     * @param string $id
27
     *
28
     * @throws Exception
29
     */
30
    public function __construct(string $type, string $id)
31
    {
32
        $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...
33
        $this->id   = $id;
34
    }
35
36
    /**
37
     * @return AnnotationType
38
     */
39
    public function getType(): AnnotationType
40
    {
41
        return $this->type;
42
    }
43
44
    /**
45
     * @return bool
46
     */
47
    public function hasId(): bool
48
    {
49
        return !empty($this->id);
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getId(): string
56
    {
57
        return $this->id;
58
    }
59
60
    /**
61
     * @return string
62
     */
63
    public function getName(): string
64
    {
65
        return substr($this->id, 1);
66
    }
67
}
68