Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
6 / 6 |
| MongoAggregator | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
6 / 6 |
| raw | |
100.00% |
1 / 1 |
1 | |
100.00% |
6 / 6 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Qmp\Laravel\MongoLow; |
| 4 | |
| 5 | use Qmp\Laravel\MongoLow\MongoPipeline; |
| 6 | abstract class MongoAggregator |
| 7 | { |
| 8 | /** |
| 9 | * Undocumented function |
| 10 | * |
| 11 | * @param Qmp\Laravel\MongoLow\Model\AbstractQmpMoloquent $model |
| 12 | * @param Qmp\Laravel\MongoLow\MongoPipeline $pipeline |
| 13 | * @return Illuminate\Database\Eloquent\Collection |
| 14 | */ |
| 15 | public static function raw($model, MongoPipeline $pipeline, array $options = []) : \Illuminate\Database\Eloquent\Collection |
| 16 | { |
| 17 | $pipelineArray = (array)\MongoDB\BSON\toPHP(\MongoDB\BSON\fromJSON(json_encode($pipeline->toArray()))); |
| 18 | $pipeline->clear(); |
| 19 | |
| 20 | |
| 21 | return $model->raw( |
| 22 | function ($collection) use ($pipelineArray, $options) { |
| 23 | return $collection->aggregate($pipelineArray, $options); |
| 24 | } |
| 25 | ); |
| 26 | } |
| 27 | } |