Repository navigation
PHPLIB-1761 Add builder support for $top, $bottom, $topN, $bottomN expression operators - #1910
Conversation
There was a problem hiding this comment.
Pull request overview
Adds builder support for the $top, $bottom, $topN, and $bottomN aggregation expression operators (MongoDB 7.0+), complementing the existing accumulator variants. The generated classes implement ResolvesToAny/ResolvesToArray, are registered on the Expression facade via FactoryTrait, and include example pipeline tests.
Changes:
- New operator classes
BottomOperator,BottomNOperator,TopOperator,TopNOperatorwithsortBy/output/input(andn) properties and string/list validation for$inputand$n. - Factory methods
bottom(),bottomN(),top(),topN()added toExpression\FactoryTrait. - Example pipeline tests and corresponding canonical JSON cases in
Pipelinesenum.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Builder/Expression/BottomOperator.php | Generated $bottom expression operator class. |
| src/Builder/Expression/BottomNOperator.php | Generated $bottomN expression operator class with n validation. |
| src/Builder/Expression/TopOperator.php | Generated $top expression operator class. |
| src/Builder/Expression/TopNOperator.php | Generated $topN expression operator class with n validation. |
| src/Builder/Expression/FactoryTrait.php | Factory methods exposing the four operators on Expression. |
| tests/Builder/Expression/BottomOperatorTest.php | Pipeline example test for $bottom. |
| tests/Builder/Expression/BottomNOperatorTest.php | Pipeline example test for $bottomN. |
| tests/Builder/Expression/TopOperatorTest.php | Pipeline example test for $top. |
| tests/Builder/Expression/TopNOperatorTest.php | Pipeline example test for $topN. |
| tests/Builder/Expression/Pipelines.php | Expected canonical extended JSON for the four new examples. |
…pression operators
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v2.x #1910 +/- ##
============================================
- Coverage 87.70% 87.64% -0.07%
- Complexity 3366 3394 +28
============================================
Files 458 462 +4
Lines 6720 6766 +46
============================================
+ Hits 5894 5930 +36
- Misses 826 836 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…pression operators (mongodb#1910)
Fix PHPLIB-1761