1 | <?php |
||
11 | class CountIterator implements InfiniteIterableInterface |
||
12 | { |
||
13 | use InfiniteIterableTrait; |
||
14 | |||
15 | /** @var int */ |
||
16 | protected $start; |
||
17 | |||
18 | /** @var int */ |
||
19 | protected $step; |
||
20 | |||
21 | /** @var int */ |
||
22 | protected $key; |
||
23 | |||
24 | /** |
||
25 | * @param int $start |
||
26 | * @param int $step |
||
27 | */ |
||
28 | 31 | public function __construct($start, $step) |
|
29 | { |
||
30 | 31 | $this->start = $start; |
|
31 | 31 | $this->step = $step; |
|
32 | 31 | $this->key = 0; |
|
33 | 31 | } |
|
34 | |||
35 | /** |
||
36 | * {@inheritDoc} |
||
37 | */ |
||
38 | 31 | public function rewind() |
|
39 | { |
||
40 | 31 | $this->key = 0; |
|
41 | 31 | } |
|
42 | |||
43 | /** |
||
44 | * {@inheritDoc} |
||
45 | */ |
||
46 | 31 | public function current() |
|
47 | { |
||
48 | 31 | return $this->start + ($this->key * $this->step); |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * {@inheritDoc} |
||
53 | */ |
||
54 | 31 | public function key() |
|
58 | |||
59 | /** |
||
60 | * {@inheritDoc} |
||
61 | */ |
||
62 | 31 | public function next() |
|
66 | |||
67 | /** |
||
68 | * {@inheritDoc} |
||
69 | */ |
||
70 | 31 | public function valid() |
|
74 | |||
75 | /** |
||
76 | * This method is called by var_dump() when dumping an object to get the properties that should be shown. |
||
77 | * |
||
78 | * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.debuginfo |
||
79 | * @return array |
||
80 | */ |
||
81 | 1 | public function __debugInfo() // phpcs:ignore Zicht.NamingConventions.Functions.MethodNaming |
|
93 | } |
||
94 |