1 | <?php |
||
11 | class StringIterator implements FiniteIterableInterface |
||
12 | { |
||
13 | use FiniteIterableTrait; |
||
14 | |||
15 | /** @var string */ |
||
16 | protected $string; |
||
17 | |||
18 | /** @var int */ |
||
19 | protected $key; |
||
20 | |||
21 | /** |
||
22 | * @param string $string |
||
23 | */ |
||
24 | 8 | public function __construct($string) |
|
25 | { |
||
26 | 8 | $this->string = $string; |
|
27 | 8 | $this->key = 0; |
|
28 | 8 | } |
|
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | 7 | public function rewind() |
|
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | 4 | public function current() |
|
42 | { |
||
43 | 4 | return $this->string[$this->key]; |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | 4 | public function key() |
|
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | 4 | public function next() |
|
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | 8 | public function valid() |
|
69 | } |
||
70 |