1 | <?php |
||
25 | abstract class AbstractCursor |
||
26 | { |
||
27 | use ReadPreference; |
||
28 | |||
29 | /** |
||
30 | * @var int |
||
31 | */ |
||
32 | protected $batchSize; |
||
33 | |||
34 | /** |
||
35 | * @var Collection |
||
36 | */ |
||
37 | protected $collection; |
||
38 | |||
39 | /** |
||
40 | * @var \MongoClient |
||
41 | */ |
||
42 | protected $connection; |
||
43 | |||
44 | /** |
||
45 | * @var Cursor |
||
46 | */ |
||
47 | protected $cursor; |
||
48 | |||
49 | /** |
||
50 | * @var \MongoDB\Database |
||
51 | */ |
||
52 | protected $db; |
||
53 | |||
54 | /** |
||
55 | * @var \IteratorIterator |
||
56 | */ |
||
57 | protected $iterator; |
||
58 | |||
59 | /** |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $ns; |
||
63 | |||
64 | /** |
||
65 | * @var array |
||
66 | */ |
||
67 | protected $optionNames = [ |
||
68 | 'batchSize', |
||
69 | 'readPreference', |
||
70 | ]; |
||
71 | |||
72 | /** |
||
73 | * @return Cursor |
||
74 | */ |
||
75 | abstract protected function ensureCursor(); |
||
76 | |||
77 | /** |
||
78 | * @return array |
||
79 | */ |
||
80 | abstract protected function getCursorInfo(); |
||
81 | |||
82 | /** |
||
83 | * Create a new cursor |
||
84 | * @link http://www.php.net/manual/en/mongocursor.construct.php |
||
85 | * @param \MongoClient $connection Database connection. |
||
86 | * @param string $ns Full name of database and collection. |
||
87 | */ |
||
88 | 31 | public function __construct(\MongoClient $connection, $ns) |
|
103 | |||
104 | /** |
||
105 | * Returns the current element |
||
106 | * @link http://www.php.net/manual/en/mongocursor.current.php |
||
107 | * @return array |
||
108 | */ |
||
109 | 10 | public function current() |
|
118 | |||
119 | /** |
||
120 | * Returns the current result's _id |
||
121 | * @link http://www.php.net/manual/en/mongocursor.key.php |
||
122 | * @return string The current result's _id as a string. |
||
123 | */ |
||
124 | 10 | public function key() |
|
128 | |||
129 | /** |
||
130 | * Advances the cursor to the next result |
||
131 | * @link http://www.php.net/manual/en/mongocursor.next.php |
||
132 | * @throws \MongoConnectionException |
||
133 | * @throws \MongoCursorTimeoutException |
||
134 | * @return void |
||
135 | */ |
||
136 | 10 | public function next() |
|
140 | |||
141 | /** |
||
142 | * Returns the cursor to the beginning of the result set |
||
143 | * @throws \MongoConnectionException |
||
144 | * @throws \MongoCursorTimeoutException |
||
145 | * @return void |
||
146 | */ |
||
147 | 28 | public function rewind() |
|
153 | |||
154 | /** |
||
155 | * Checks if the cursor is reading a valid result. |
||
156 | * @link http://www.php.net/manual/en/mongocursor.valid.php |
||
157 | * @return boolean If the current result is not null. |
||
158 | */ |
||
159 | 26 | public function valid() |
|
163 | |||
164 | /** |
||
165 | * Limits the number of elements returned in one batch. |
||
166 | * |
||
167 | * @link http://docs.php.net/manual/en/mongocursor.batchsize.php |
||
168 | * @param int $batchSize The number of results to return per batch |
||
169 | * @return $this Returns this cursor. |
||
170 | */ |
||
171 | 1 | public function batchSize($batchSize) |
|
177 | |||
178 | /** |
||
179 | * Checks if there are documents that have not been sent yet from the database for this cursor |
||
180 | * @link http://www.php.net/manual/en/mongocursor.dead.php |
||
181 | * @return boolean Returns if there are more results that have not been sent to the client, yet. |
||
182 | */ |
||
183 | public function dead() |
||
187 | |||
188 | /** |
||
189 | * @return array |
||
190 | */ |
||
191 | 2 | public function info() |
|
195 | |||
196 | /** |
||
197 | * @link http://www.php.net/manual/en/mongocursor.setreadpreference.php |
||
198 | * @param string $readPreference |
||
199 | * @param array $tags |
||
200 | * @return $this Returns this cursor. |
||
201 | */ |
||
202 | 31 | public function setReadPreference($readPreference, $tags = null) |
|
208 | |||
209 | /** |
||
210 | * Sets a client-side timeout for this query |
||
211 | * @link http://www.php.net/manual/en/mongocursor.timeout.php |
||
212 | * @param int $ms The number of milliseconds for the cursor to wait for a response. By default, the cursor will wait forever. |
||
213 | * @return $this Returns this cursor |
||
214 | */ |
||
215 | public function timeout($ms) |
||
219 | |||
220 | /** |
||
221 | * Applies all options set on the cursor, overwriting any options that have already been set |
||
222 | * |
||
223 | * @param array $optionNames Array of option names to be applied (will be read from properties) |
||
224 | * @return array |
||
225 | */ |
||
226 | 29 | protected function getOptions($optionNames = null) |
|
247 | |||
248 | /** |
||
249 | * @return \IteratorIterator |
||
250 | */ |
||
251 | 28 | protected function ensureIterator() |
|
259 | |||
260 | /** |
||
261 | * @throws \MongoCursorException |
||
262 | */ |
||
263 | 14 | protected function errorIfOpened() |
|
271 | |||
272 | /** |
||
273 | * @return array |
||
274 | */ |
||
275 | 2 | protected function getIterationInfo() |
|
312 | |||
313 | /** |
||
314 | * @throws \Exception |
||
315 | */ |
||
316 | protected function notImplemented() |
||
320 | |||
321 | /** |
||
322 | * Clears the cursor |
||
323 | * |
||
324 | * This is generic but implemented as protected since it's only exposed in MongoCursor |
||
325 | */ |
||
326 | 28 | protected function reset() |
|
331 | } |
||
332 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.