Total Complexity | 8 |
Total Lines | 68 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | final class StringInput implements IteratorAggregate, SymbolReaderInterface |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | private $data; |
||
19 | |||
20 | /** |
||
21 | * @var int |
||
22 | */ |
||
23 | private $offset = 0; |
||
24 | |||
25 | /** |
||
26 | * @var int |
||
27 | */ |
||
28 | private $length; |
||
29 | |||
30 | 20 | public function __construct(string $data) |
|
31 | { |
||
32 | 20 | $this->data = $data; |
|
33 | 20 | $this->length = strlen($data); |
|
34 | 20 | } |
|
35 | |||
36 | /** |
||
37 | * @return bool |
||
38 | * @psalm-pure |
||
39 | */ |
||
40 | 6 | public function isFinished(): bool |
|
41 | { |
||
42 | 6 | return $this->length == $this->offset; |
|
43 | } |
||
44 | |||
45 | 14 | public function read(): SymbolInterface |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return int |
||
56 | * @psalm-pure |
||
57 | */ |
||
58 | 5 | public function getOffset(): int |
|
59 | { |
||
60 | 5 | return $this->offset; |
|
61 | } |
||
62 | |||
63 | /** |
||
64 | * @return LexemeInterface |
||
65 | * @psalm-pure |
||
66 | */ |
||
67 | 4 | public function getEmptyLexeme(): LexemeInterface |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return Iterator |
||
74 | * @psalm-return Iterator<int,SymbolInterface> |
||
75 | */ |
||
76 | 3 | public function getIterator(): Iterator |
|
80 | } |
||
81 | 3 | } |
|
83 |