Total Complexity | 7 |
Total Lines | 100 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | final class Token implements TokenInterface |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @var int |
||
17 | */ |
||
18 | private $id; |
||
19 | |||
20 | /** |
||
21 | * @var int |
||
22 | */ |
||
23 | private $offset; |
||
24 | |||
25 | /** |
||
26 | * @var LexemeInterface |
||
27 | */ |
||
28 | private $lexeme; |
||
29 | |||
30 | /** |
||
31 | * @var AttributeCollectionInterface |
||
32 | */ |
||
33 | private $attributes; |
||
34 | |||
35 | /** |
||
36 | * @param int $offset |
||
37 | * @param LexemeInterface $lexeme |
||
38 | * @param AttributeCollectionInterface|null $attributes |
||
39 | * @return TokenInterface |
||
40 | */ |
||
41 | 5 | public static function createEoi( |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * Token constructor. |
||
51 | * |
||
52 | * @param int $id |
||
53 | * @param int $offset |
||
54 | * @param LexemeInterface $lexeme |
||
55 | * @param AttributeCollectionInterface|null $attributes |
||
56 | */ |
||
57 | 12 | public function __construct( |
|
58 | int $id, |
||
59 | int $offset, |
||
60 | LexemeInterface $lexeme, |
||
61 | ?AttributeCollectionInterface $attributes = null |
||
62 | ) { |
||
63 | 12 | $this->id = $id; |
|
64 | 12 | $this->offset = $offset; |
|
65 | 12 | $this->lexeme = $lexeme; |
|
66 | 12 | $this->attributes = $attributes ?? new AttributeCollection(); |
|
67 | 12 | } |
|
68 | |||
69 | /** |
||
70 | * @return int |
||
71 | * @psalm-pure |
||
72 | */ |
||
73 | 2 | public function getId(): int |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * @return int |
||
80 | * @psalm-pure |
||
81 | */ |
||
82 | 2 | public function getOffset(): int |
|
83 | { |
||
84 | 2 | return $this->offset; |
|
85 | } |
||
86 | |||
87 | /** |
||
88 | * @return LexemeInterface |
||
89 | * @psalm-pure |
||
90 | */ |
||
91 | 2 | public function getLexeme(): LexemeInterface |
|
92 | { |
||
93 | 2 | return $this->lexeme; |
|
94 | } |
||
95 | |||
96 | /** |
||
97 | * @return AttributeCollectionInterface |
||
98 | * @psalm-pure |
||
99 | */ |
||
100 | 4 | public function getAttributes(): AttributeCollectionInterface |
|
101 | { |
||
102 | 4 | return $this->attributes; |
|
103 | } |
||
104 | |||
105 | /** |
||
106 | * @return bool |
||
107 | * @psalm-pure |
||
108 | */ |
||
109 | 2 | public function isFinal(): bool |
|
112 | } |
||
113 | } |
||
114 |