1 | <?php |
||
32 | abstract class Stage |
||
33 | { |
||
34 | /** |
||
35 | * @var Builder |
||
36 | */ |
||
37 | protected $builder; |
||
38 | |||
39 | /** |
||
40 | * @param Builder $builder |
||
41 | */ |
||
42 | 253 | public function __construct(Builder $builder) |
|
46 | |||
47 | /** |
||
48 | * Assembles the aggregation stage |
||
49 | * |
||
50 | * @return array |
||
51 | */ |
||
52 | abstract public function getExpression(); |
||
53 | |||
54 | /** |
||
55 | * Executes the aggregation pipeline |
||
56 | * |
||
57 | * @param array $options |
||
58 | * @return Iterator |
||
59 | */ |
||
60 | 1 | public function execute($options = []) |
|
64 | |||
65 | /** |
||
66 | * Categorizes incoming documents into groups, called buckets, based on a |
||
67 | * specified expression and bucket boundaries. |
||
68 | * |
||
69 | * Each bucket is represented as a document in the output. The document for |
||
70 | * each bucket contains an _id field, whose value specifies the inclusive |
||
71 | * lower bound of the bucket and a count field that contains the number of |
||
72 | * documents in the bucket. The count field is included by default when the |
||
73 | * output is not specified. |
||
74 | * |
||
75 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/bucket/ |
||
76 | * |
||
77 | * @return Stage\Bucket |
||
78 | */ |
||
79 | public function bucket() |
||
83 | |||
84 | /** |
||
85 | * Categorizes incoming documents into a specific number of groups, called |
||
86 | * buckets, based on a specified expression. |
||
87 | * |
||
88 | * Bucket boundaries are automatically determined in an attempt to evenly |
||
89 | * distribute the documents into the specified number of buckets. Each |
||
90 | * bucket is represented as a document in the output. The document for each |
||
91 | * bucket contains an _id field, whose value specifies the inclusive lower |
||
92 | * bound and the exclusive upper bound for the bucket, and a count field |
||
93 | * that contains the number of documents in the bucket. The count field is |
||
94 | * included by default when the output is not specified. |
||
95 | * |
||
96 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/bucketAuto/ |
||
97 | * |
||
98 | * @return Stage\BucketAuto |
||
99 | */ |
||
100 | public function bucketAuto() |
||
104 | |||
105 | /** |
||
106 | * Returns statistics regarding a collection or view. |
||
107 | * |
||
108 | * $collStats must be the first stage in an aggregation pipeline, or else |
||
109 | * the pipeline returns an error. |
||
110 | * |
||
111 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/geoNear/ |
||
112 | * @since 1.5 |
||
113 | * |
||
114 | * @return Stage\CollStats |
||
115 | */ |
||
116 | public function collStats() |
||
120 | |||
121 | /** |
||
122 | * Returns a document that contains a count of the number of documents input |
||
123 | * to the stage. |
||
124 | * |
||
125 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/count/ |
||
126 | * |
||
127 | * @return Stage\Count |
||
128 | */ |
||
129 | public function count($fieldName) |
||
133 | |||
134 | /** |
||
135 | * Processes multiple aggregation pipelines within a single stage on the |
||
136 | * same set of input documents. |
||
137 | * |
||
138 | * Each sub-pipeline has its own field in the output document where its |
||
139 | * results are stored as an array of documents. |
||
140 | * |
||
141 | * @return Stage\Facet |
||
142 | */ |
||
143 | public function facet() |
||
147 | |||
148 | /** |
||
149 | * Outputs documents in order of nearest to farthest from a specified point. |
||
150 | * You can only use this as the first stage of a pipeline. |
||
151 | * |
||
152 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/geoNear/ |
||
153 | * |
||
154 | * @param float|array|Point $x |
||
155 | * @param float $y |
||
156 | * @return Stage\GeoNear |
||
157 | */ |
||
158 | public function geoNear($x, $y = null) |
||
162 | |||
163 | /** |
||
164 | * Returns the assembled aggregation pipeline |
||
165 | * |
||
166 | * @return array |
||
167 | */ |
||
168 | public function getPipeline() |
||
172 | |||
173 | /** |
||
174 | * Performs a recursive search on a collection, with options for restricting |
||
175 | * the search by recursion depth and query filter. |
||
176 | * |
||
177 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/graphLookup/ |
||
178 | * |
||
179 | * @param string $from Target collection for the $graphLookup operation to |
||
180 | * search, recursively matching the connectFromField to the connectToField. |
||
181 | * @return Stage\GraphLookup |
||
182 | */ |
||
183 | public function graphLookup($from) |
||
187 | |||
188 | /** |
||
189 | * Groups documents by some specified expression and outputs to the next |
||
190 | * stage a document for each distinct grouping. |
||
191 | * |
||
192 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/group/ |
||
193 | * |
||
194 | * @return Stage\Group |
||
195 | */ |
||
196 | 2 | public function group() |
|
200 | |||
201 | /** |
||
202 | * Returns statistics regarding the use of each index for the collection. |
||
203 | * |
||
204 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/indexStats/ |
||
205 | * |
||
206 | * @return Stage\IndexStats |
||
207 | */ |
||
208 | public function indexStats() |
||
212 | |||
213 | /** |
||
214 | * Limits the number of documents passed to the next stage in the pipeline. |
||
215 | * |
||
216 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/limit/ |
||
217 | * |
||
218 | * @param integer $limit |
||
219 | * @return Stage\Limit |
||
220 | */ |
||
221 | 1 | public function limit($limit) |
|
225 | |||
226 | /** |
||
227 | * Performs a left outer join to an unsharded collection in the same |
||
228 | * database to filter in documents from the “joined” collection for |
||
229 | * processing. |
||
230 | * |
||
231 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/lookup/ |
||
232 | * |
||
233 | * @param string $from |
||
234 | * @return Stage\Lookup |
||
235 | */ |
||
236 | 7 | public function lookup($from) |
|
240 | |||
241 | /** |
||
242 | * Filters the documents to pass only the documents that match the specified |
||
243 | * condition(s) to the next pipeline stage. |
||
244 | * |
||
245 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/match/ |
||
246 | * |
||
247 | * @return Stage\Match |
||
248 | */ |
||
249 | 1 | public function match() |
|
253 | |||
254 | /** |
||
255 | * Takes the documents returned by the aggregation pipeline and writes them |
||
256 | * to a specified collection. This must be the last stage in the pipeline. |
||
257 | * |
||
258 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/out/ |
||
259 | * |
||
260 | * @param string $collection |
||
261 | * @return Stage\Out |
||
262 | */ |
||
263 | 1 | public function out($collection) |
|
267 | |||
268 | /** |
||
269 | * Passes along the documents with only the specified fields to the next |
||
270 | * stage in the pipeline. The specified fields can be existing fields from |
||
271 | * the input documents or newly computed fields. |
||
272 | * |
||
273 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/project/ |
||
274 | * |
||
275 | * @return Stage\Project |
||
276 | */ |
||
277 | 2 | public function project() |
|
281 | |||
282 | /** |
||
283 | * Restricts the contents of the documents based on information stored in |
||
284 | * the documents themselves. |
||
285 | * |
||
286 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/redact/ |
||
287 | * |
||
288 | * @return Stage\Redact |
||
289 | */ |
||
290 | 1 | public function redact() |
|
294 | |||
295 | /** |
||
296 | * Promotes a specified document to the top level and replaces all other |
||
297 | * fields. |
||
298 | * |
||
299 | * The operation replaces all existing fields in the input document, |
||
300 | * including the _id field. You can promote an existing embedded document to |
||
301 | * the top level, or create a new document for promotion. |
||
302 | * |
||
303 | * @param string|null $expression Optional. A replacement expression that |
||
304 | * resolves to a document. |
||
305 | * |
||
306 | * @return Stage\ReplaceRoot |
||
307 | */ |
||
308 | 2 | public function replaceRoot($expression = null) |
|
312 | |||
313 | /** |
||
314 | * Randomly selects the specified number of documents from its input. |
||
315 | * |
||
316 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/sample/ |
||
317 | * |
||
318 | * @param integer $size |
||
319 | * @return Stage\Sample |
||
320 | */ |
||
321 | 1 | public function sample($size) |
|
325 | |||
326 | /** |
||
327 | * Skips over the specified number of documents that pass into the stage and |
||
328 | * passes the remaining documents to the next stage in the pipeline. |
||
329 | * |
||
330 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/skip/ |
||
331 | * |
||
332 | * @param integer $skip |
||
333 | * @return Stage\Skip |
||
334 | */ |
||
335 | 1 | public function skip($skip) |
|
339 | |||
340 | /** |
||
341 | * Groups incoming documents based on the value of a specified expression, |
||
342 | * then computes the count of documents in each distinct group. |
||
343 | * |
||
344 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/sortByCount/ |
||
345 | * |
||
346 | * @param string $expression The expression to group by |
||
347 | * @return Stage\SortByCount |
||
348 | */ |
||
349 | public function sortByCount($expression) |
||
353 | |||
354 | /** |
||
355 | * Sorts all input documents and returns them to the pipeline in sorted order. |
||
356 | * |
||
357 | * If sorting by multiple fields, the first argument should be an array of |
||
358 | * field name (key) and order (value) pairs. |
||
359 | * |
||
360 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/sort/ |
||
361 | * |
||
362 | * @param array|string $fieldName Field name or array of field/order pairs |
||
363 | * @param integer|string $order Field order (if one field is specified) |
||
364 | * @return Stage\Sort |
||
365 | */ |
||
366 | 3 | public function sort($fieldName, $order = null) |
|
370 | |||
371 | /** |
||
372 | * Deconstructs an array field from the input documents to output a document |
||
373 | * for each element. Each output document is the input document with the |
||
374 | * value of the array field replaced by the element. |
||
375 | * |
||
376 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/unwind/ |
||
377 | * |
||
378 | * @param string $fieldName The field to unwind. It is automatically prefixed with the $ sign |
||
379 | * @return Stage\Unwind |
||
380 | */ |
||
381 | 3 | public function unwind($fieldName) |
|
385 | } |
||
386 |