1 | <?php |
||
15 | class ResultSet implements \Iterator, \Countable, \ArrayAccess |
||
16 | { |
||
17 | /** |
||
18 | * Results. |
||
19 | * |
||
20 | * @var Result[] Results |
||
21 | */ |
||
22 | private $_results = array(); |
||
23 | |||
24 | /** |
||
25 | * Current position. |
||
26 | * |
||
27 | * @var int Current position |
||
28 | */ |
||
29 | private $_position = 0; |
||
30 | |||
31 | /** |
||
32 | * Response. |
||
33 | * |
||
34 | * @var \Elastica\Response Response object |
||
35 | */ |
||
36 | private $_response; |
||
37 | |||
38 | /** |
||
39 | * Query. |
||
40 | * |
||
41 | * @var \Elastica\Query Query object |
||
42 | */ |
||
43 | private $_query; |
||
44 | |||
45 | /** |
||
46 | * Constructs ResultSet object. |
||
47 | * |
||
48 | * @param Response $response Response object |
||
49 | * @param Query $query Query object |
||
50 | * @param Result[] $results |
||
51 | */ |
||
52 | public function __construct(Response $response, Query $query, $results) |
||
58 | |||
59 | /** |
||
60 | * Returns all results. |
||
61 | * |
||
62 | * @return Result[] Results |
||
63 | */ |
||
64 | public function getResults() |
||
68 | |||
69 | /** |
||
70 | * Returns all Documents. |
||
71 | * |
||
72 | * @return array Documents \Elastica\Document |
||
73 | */ |
||
74 | public function getDocuments() |
||
83 | |||
84 | /** |
||
85 | * Returns true if the response contains suggestion results; false otherwise. |
||
86 | * |
||
87 | * @return bool |
||
88 | */ |
||
89 | public function hasSuggests() |
||
95 | |||
96 | /** |
||
97 | * Return all suggests. |
||
98 | * |
||
99 | * @return array suggest results |
||
100 | */ |
||
101 | public function getSuggests() |
||
107 | |||
108 | /** |
||
109 | * Returns whether aggregations exist. |
||
110 | * |
||
111 | * @return bool Aggregation existence |
||
112 | */ |
||
113 | public function hasAggregations() |
||
119 | |||
120 | /** |
||
121 | * Returns all aggregation results. |
||
122 | * |
||
123 | * @return array |
||
124 | */ |
||
125 | public function getAggregations() |
||
131 | |||
132 | /** |
||
133 | * Retrieve a specific aggregation from this result set. |
||
134 | * |
||
135 | * @param string $name the name of the desired aggregation |
||
136 | * |
||
137 | * @throws Exception\InvalidException if an aggregation by the given name cannot be found |
||
138 | * |
||
139 | * @return array |
||
140 | */ |
||
141 | public function getAggregation($name) |
||
150 | |||
151 | /** |
||
152 | * Returns the total number of found hits. |
||
153 | * |
||
154 | * @return int Total hits |
||
155 | */ |
||
156 | public function getTotalHits() |
||
160 | |||
161 | /** |
||
162 | * Returns the max score of the results found. |
||
163 | * |
||
164 | * @return float Max Score |
||
165 | */ |
||
166 | public function getMaxScore() |
||
170 | |||
171 | /** |
||
172 | * Returns the total number of ms for this search to complete. |
||
173 | * |
||
174 | * @return int Total time |
||
175 | */ |
||
176 | public function getTotalTime() |
||
180 | |||
181 | /** |
||
182 | * Returns true if the query has timed out. |
||
183 | * |
||
184 | * @return bool Timed out |
||
185 | */ |
||
186 | public function hasTimedOut() |
||
190 | |||
191 | /** |
||
192 | * Returns response object. |
||
193 | * |
||
194 | * @return \Elastica\Response Response object |
||
195 | */ |
||
196 | public function getResponse() |
||
200 | |||
201 | /** |
||
202 | * @return \Elastica\Query |
||
203 | */ |
||
204 | public function getQuery() |
||
208 | |||
209 | /** |
||
210 | * Returns size of current set. |
||
211 | * |
||
212 | * @return int Size of set |
||
213 | */ |
||
214 | public function count() |
||
218 | |||
219 | /** |
||
220 | * Returns size of current suggests. |
||
221 | * |
||
222 | * @return int Size of suggests |
||
223 | */ |
||
224 | public function countSuggests() |
||
228 | |||
229 | /** |
||
230 | * Returns the current object of the set. |
||
231 | * |
||
232 | * @return \Elastica\Result|bool Set object or false if not valid (no more entries) |
||
233 | */ |
||
234 | public function current() |
||
242 | |||
243 | /** |
||
244 | * Sets pointer (current) to the next item of the set. |
||
245 | */ |
||
246 | public function next() |
||
252 | |||
253 | /** |
||
254 | * Returns the position of the current entry. |
||
255 | * |
||
256 | * @return int Current position |
||
257 | */ |
||
258 | public function key() |
||
262 | |||
263 | /** |
||
264 | * Check if an object exists at the current position. |
||
265 | * |
||
266 | * @return bool True if object exists |
||
267 | */ |
||
268 | public function valid() |
||
272 | |||
273 | /** |
||
274 | * Resets position to 0, restarts iterator. |
||
275 | */ |
||
276 | public function rewind() |
||
280 | |||
281 | /** |
||
282 | * Whether a offset exists. |
||
283 | * |
||
284 | * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
||
285 | * |
||
286 | * @param int $offset |
||
287 | * |
||
288 | * @return bool true on success or false on failure. |
||
289 | */ |
||
290 | public function offsetExists($offset) |
||
294 | |||
295 | /** |
||
296 | * Offset to retrieve. |
||
297 | * |
||
298 | * @link http://php.net/manual/en/arrayaccess.offsetget.php |
||
299 | * |
||
300 | * @param int $offset |
||
301 | * |
||
302 | * @throws Exception\InvalidException If offset doesn't exist |
||
303 | * |
||
304 | * @return Result|null |
||
305 | */ |
||
306 | public function offsetGet($offset) |
||
314 | |||
315 | /** |
||
316 | * Offset to set. |
||
317 | * |
||
318 | * @link http://php.net/manual/en/arrayaccess.offsetset.php |
||
319 | * |
||
320 | * @param int $offset |
||
321 | * @param Result $value |
||
322 | * |
||
323 | * @throws Exception\InvalidException |
||
324 | */ |
||
325 | public function offsetSet($offset, $value) |
||
337 | |||
338 | /** |
||
339 | * Offset to unset. |
||
340 | * |
||
341 | * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
||
342 | * |
||
343 | * @param int $offset |
||
344 | */ |
||
345 | public function offsetUnset($offset) |
||
349 | } |
||
350 |
This check looks for calls to
isset(...)
orempty()
on variables that are yet undefined. These calls will always produce the same result and can be removed.This is most likely caused by the renaming of a variable or the removal of a function/method parameter.