1 | <?php |
||
14 | class QScanIterator extends AbstractClient implements \Iterator { |
||
15 | |||
16 | /** |
||
17 | * @var int Current disque cursor. |
||
18 | */ |
||
19 | private $cursor = -1; |
||
20 | |||
21 | /** |
||
22 | * @var array returned elements. |
||
23 | */ |
||
24 | private $elements = []; |
||
25 | |||
26 | /** |
||
27 | * @var int current iterator index. |
||
28 | */ |
||
29 | private $index = 0; |
||
30 | |||
31 | /** |
||
32 | * Pagination count per call. |
||
33 | * |
||
34 | * @var int |
||
35 | */ |
||
36 | private $count = 100; |
||
37 | |||
38 | /** |
||
39 | * @var int |
||
40 | */ |
||
41 | private $min = 0; |
||
42 | |||
43 | /** |
||
44 | * @var int |
||
45 | */ |
||
46 | private $max = 0; |
||
47 | |||
48 | /** |
||
49 | * @var int |
||
50 | */ |
||
51 | private $rate = 0; |
||
52 | |||
53 | |||
54 | /** |
||
55 | * @param StreamInterface $stream |
||
56 | * @param LoggerInterface|null $log |
||
57 | */ |
||
58 | 8 | public function __construct(StreamInterface $stream, LoggerInterface $log = null) |
|
62 | |||
63 | 4 | private function scan() |
|
102 | |||
103 | |||
104 | /** |
||
105 | * Return the current element |
||
106 | * |
||
107 | * @link http://php.net/manual/en/iterator.current.php |
||
108 | * @return string the next queue name |
||
109 | */ |
||
110 | 3 | public function current() |
|
114 | |||
115 | /** |
||
116 | * Move forward to next element |
||
117 | * |
||
118 | * @link http://php.net/manual/en/iterator.next.php |
||
119 | */ |
||
120 | 3 | public function next() |
|
124 | |||
125 | /** |
||
126 | * Return the key of the current element |
||
127 | * |
||
128 | * @link http://php.net/manual/en/iterator.key.php |
||
129 | * @return int scalar on success, or null on failure. |
||
130 | */ |
||
131 | 2 | public function key() |
|
135 | |||
136 | /** |
||
137 | * Checks if current position is valid |
||
138 | * |
||
139 | * @link http://php.net/manual/en/iterator.valid.php |
||
140 | * @return boolean true on success or false on failure. |
||
141 | */ |
||
142 | 4 | public function valid() |
|
151 | |||
152 | /** |
||
153 | * Rewind the Iterator to the first element |
||
154 | * |
||
155 | * @link http://php.net/manual/en/iterator.rewind.php |
||
156 | */ |
||
157 | 2 | public function rewind() |
|
161 | |||
162 | |||
163 | /** |
||
164 | * @param int $count |
||
165 | * @return QScanIterator |
||
166 | */ |
||
167 | 5 | public function setCount($count) |
|
172 | |||
173 | |||
174 | /** |
||
175 | * Set the minimum queue size. |
||
176 | * |
||
177 | * @param int $min min >= 0 |
||
178 | * @return QScanIterator |
||
179 | */ |
||
180 | 3 | public function setMin($min) |
|
185 | |||
186 | /** |
||
187 | * @param int $max |
||
188 | * @return QScanIterator |
||
189 | */ |
||
190 | 3 | public function setMax($max) |
|
195 | |||
196 | |||
197 | /** |
||
198 | * @param int $rate |
||
199 | * @return QScanIterator |
||
200 | */ |
||
201 | 5 | public function setRate($rate) |
|
206 | } |
||
207 |