1 | <?php |
||
13 | class RepeatIterator implements \Countable, InfiniteIterableInterface |
||
14 | { |
||
15 | use InfiniteIterableTrait; |
||
16 | |||
17 | /** @var mixed */ |
||
18 | private $mixed; |
||
19 | |||
20 | /** @var int */ |
||
21 | private $times; |
||
22 | |||
23 | /** @var int */ |
||
24 | private $key; |
||
25 | |||
26 | /** |
||
27 | * @param mixed $mixed |
||
28 | * @param int $times |
||
29 | */ |
||
30 | 5 | public function __construct($mixed, $times) |
|
31 | { |
||
32 | 5 | $this->mixed = $mixed; |
|
33 | 5 | $this->times = $times; |
|
34 | 5 | $this->key = 0; |
|
35 | 5 | } |
|
36 | |||
37 | /** |
||
38 | * {@inheritDoc} |
||
39 | */ |
||
40 | 5 | public function rewind() |
|
41 | { |
||
42 | 5 | $this->key = 0; |
|
43 | 5 | } |
|
44 | |||
45 | /** |
||
46 | * {@inheritDoc} |
||
47 | */ |
||
48 | 4 | public function current() |
|
52 | |||
53 | /** |
||
54 | * {@inheritDoc} |
||
55 | */ |
||
56 | 4 | public function key() |
|
57 | { |
||
58 | 4 | return $this->key; |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * {@inheritDoc} |
||
63 | */ |
||
64 | 4 | public function next() |
|
65 | { |
||
66 | 4 | $this->key += 1; |
|
67 | 4 | } |
|
68 | |||
69 | /** |
||
70 | * {@inheritDoc} |
||
71 | */ |
||
72 | 5 | public function valid() |
|
76 | |||
77 | /** |
||
78 | * {@inheritDoc} |
||
79 | */ |
||
80 | 5 | public function count() |
|
84 | } |
||
85 |