1 | <?php |
||
14 | class JScanIterator extends AbstractClient implements \Iterator { |
||
15 | |||
16 | const FORMAT_ID = 'id'; |
||
17 | const FORMAT_ALL = 'all'; |
||
18 | |||
19 | /** |
||
20 | * @var int Current disque cursor. |
||
21 | */ |
||
22 | private $cursor = -1; |
||
23 | |||
24 | /** |
||
25 | * @var array returned elements. |
||
26 | */ |
||
27 | private $elements = []; |
||
28 | |||
29 | /** |
||
30 | * @var int current iterator index. |
||
31 | */ |
||
32 | private $index = 0; |
||
33 | |||
34 | /** |
||
35 | * Pagination count per call. |
||
36 | * |
||
37 | * @var int |
||
38 | */ |
||
39 | private $count = 100; |
||
40 | |||
41 | /** |
||
42 | * @var string[] |
||
43 | */ |
||
44 | private $queues = []; |
||
45 | |||
46 | /** |
||
47 | * @var string[] |
||
48 | */ |
||
49 | private $states = []; |
||
50 | |||
51 | /** |
||
52 | * @var string |
||
53 | */ |
||
54 | private $format = self::FORMAT_ID; |
||
55 | |||
56 | |||
57 | /** |
||
58 | * @param StreamInterface $stream |
||
59 | * @param LoggerInterface|null $log |
||
60 | */ |
||
61 | 1 | public function __construct(StreamInterface $stream, LoggerInterface $log = null) |
|
65 | |||
66 | 1 | private function scan() |
|
106 | |||
107 | |||
108 | /** |
||
109 | * Return the current element |
||
110 | * |
||
111 | * @link http://php.net/manual/en/iterator.current.php |
||
112 | * @return string the next queue name |
||
113 | */ |
||
114 | 1 | public function current() |
|
118 | |||
119 | /** |
||
120 | * Move forward to next element |
||
121 | * |
||
122 | * @link http://php.net/manual/en/iterator.next.php |
||
123 | */ |
||
124 | 1 | public function next() |
|
128 | |||
129 | /** |
||
130 | * Return the key of the current element |
||
131 | * |
||
132 | * @link http://php.net/manual/en/iterator.key.php |
||
133 | * @return int scalar on success, or null on failure. |
||
134 | */ |
||
135 | 1 | public function key() |
|
139 | |||
140 | /** |
||
141 | * Checks if current position is valid |
||
142 | * |
||
143 | * @link http://php.net/manual/en/iterator.valid.php |
||
144 | * @return boolean true on success or false on failure. |
||
145 | */ |
||
146 | 1 | public function valid() |
|
155 | |||
156 | /** |
||
157 | * Rewind the Iterator to the first element |
||
158 | * |
||
159 | * @link http://php.net/manual/en/iterator.rewind.php |
||
160 | */ |
||
161 | 1 | public function rewind() |
|
165 | |||
166 | |||
167 | /** |
||
168 | * @param int $count |
||
169 | */ |
||
170 | 1 | public function setCount($count) |
|
174 | |||
175 | |||
176 | /** |
||
177 | * @param string[] $queues |
||
178 | */ |
||
179 | 1 | public function setQueues($queues) |
|
183 | |||
184 | |||
185 | /** |
||
186 | * @param string[] $states |
||
187 | */ |
||
188 | 1 | public function setStates($states) |
|
192 | |||
193 | |||
194 | /** |
||
195 | * @param string $format |
||
196 | */ |
||
197 | 1 | public function setFormat($format) |
|
201 | } |
||
202 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.