Skip to content

Commit 30da9a6

Browse files
committed
indentation fix
1 parent 99fe69b commit 30da9a6

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

source/includes/aggregation.php

+50-50
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,28 @@
1919
// counts each borough's matching documents
2020
// start-array-match-group
2121
$pipeline = [
22-
['$match' => ['cuisine' => 'Bakery']],
23-
['$group' => ['_id' => '$borough', 'count' => ['$sum' => 1]]],
22+
['$match' => ['cuisine' => 'Bakery']],
23+
['$group' => ['_id' => '$borough', 'count' => ['$sum' => 1]]],
2424
];
2525

2626
$cursor = $collection->aggregate($pipeline);
2727

2828
foreach ($cursor as $doc) {
29-
echo json_encode($doc), PHP_EOL;
29+
echo json_encode($doc), PHP_EOL;
3030
}
3131
// end-array-match-group
3232

3333
// Performs the same aggregation operation as above but asks MongoDB to explain it
3434
// start-array-explain
3535
$pipeline = [
36-
['$match' => ['cuisine' => 'Bakery']],
37-
['$group' => ['_id' => '$borough', 'count' => ['$sum' => 1]]],
36+
['$match' => ['cuisine' => 'Bakery']],
37+
['$group' => ['_id' => '$borough', 'count' => ['$sum' => 1]]],
3838
];
3939

4040
$aggregate = new MongoDB\Operation\Aggregate(
41-
$collection->getDatabaseName(),
42-
$collection->getCollectionName(),
43-
$pipeline
41+
$collection->getDatabaseName(),
42+
$collection->getCollectionName(),
43+
$pipeline
4444
);
4545

4646
$result = $collection->explain($aggregate);
@@ -49,73 +49,73 @@
4949

5050
// start-builder-match-group
5151
$pipeline = new Pipeline(
52-
Stage::match(
53-
date: [
54-
Query::gte(new UTCDateTime(new DateTimeImmutable('2014-01-01'))),
55-
Query::lt(new UTCDateTime(new DateTimeImmutable('2015-01-01'))),
56-
],
57-
),
58-
Stage::group(
59-
_id: Expression::dateToString(Expression::dateFieldPath('date'), '%Y-%m-%d'),
60-
totalSaleAmount: Accumulator::sum(
61-
Expression::multiply(
62-
Expression::numberFieldPath('price'),
63-
Expression::numberFieldPath('quantity'),
64-
),
65-
),
66-
averageQuantity: Accumulator::avg(
67-
Expression::numberFieldPath('quantity'),
68-
),
69-
count: Accumulator::sum(1),
70-
),
71-
Stage::sort(
72-
totalSaleAmount: Sort::Desc,
73-
),
52+
Stage::match(
53+
date: [
54+
Query::gte(new UTCDateTime(new DateTimeImmutable('2014-01-01'))),
55+
Query::lt(new UTCDateTime(new DateTimeImmutable('2015-01-01'))),
56+
],
57+
),
58+
Stage::group(
59+
_id: Expression::dateToString(Expression::dateFieldPath('date'), '%Y-%m-%d'),
60+
totalSaleAmount: Accumulator::sum(
61+
Expression::multiply(
62+
Expression::numberFieldPath('price'),
63+
Expression::numberFieldPath('quantity'),
64+
),
65+
),
66+
averageQuantity: Accumulator::avg(
67+
Expression::numberFieldPath('quantity'),
68+
),
69+
count: Accumulator::sum(1),
70+
),
71+
Stage::sort(
72+
totalSaleAmount: Sort::Desc,
73+
),
7474
);
7575

7676
$cursor = $collection->aggregate(iterator_to_array($pipeline));
7777

7878
foreach ($cursor as $doc) {
79-
echo json_encode($doc), PHP_EOL;
79+
echo json_encode($doc), PHP_EOL;
8080
}
8181
// end-builder-match-group
8282

8383
// start-builder-unwind
8484
$pipeline = new Pipeline(
85-
Stage::unwind(Expression::arrayFieldPath('items')),
86-
Stage::unwind(Expression::arrayFieldPath('items.tags')),
87-
Stage::group(
88-
_id: Expression::fieldPath('items.tags'),
89-
totalSalesAmount: Accumulator::sum(
90-
Expression::multiply(
91-
Expression::numberFieldPath('items.price'),
92-
Expression::numberFieldPath('items.quantity'),
93-
),
94-
),
95-
),
85+
Stage::unwind(Expression::arrayFieldPath('items')),
86+
Stage::unwind(Expression::arrayFieldPath('items.tags')),
87+
Stage::group(
88+
_id: Expression::fieldPath('items.tags'),
89+
totalSalesAmount: Accumulator::sum(
90+
Expression::multiply(
91+
Expression::numberFieldPath('items.price'),
92+
Expression::numberFieldPath('items.quantity'),
93+
),
94+
),
95+
),
9696
);
9797

9898
$cursor = $collection->aggregate(iterator_to_array($pipeline));
9999

100100
foreach ($cursor as $doc) {
101-
echo json_encode($doc), PHP_EOL;
101+
echo json_encode($doc), PHP_EOL;
102102
}
103103
// end-builder-unwind
104104

105105
// start-builder-lookup
106106
$pipeline = new Pipeline(
107-
Stage::lookup(
108-
from: 'inventory',
109-
localField: 'item',
110-
foreignField: 'sku',
111-
as: 'inventory_docs',
112-
),
107+
Stage::lookup(
108+
from: 'inventory',
109+
localField: 'item',
110+
foreignField: 'sku',
111+
as: 'inventory_docs',
112+
),
113113
);
114114

115115
/* Perform the aggregation on the orders collection */
116116
$cursor = $collection->aggregate(iterator_to_array($pipeline));
117117

118118
foreach ($cursor as $doc) {
119-
echo json_encode($doc), PHP_EOL;
119+
echo json_encode($doc), PHP_EOL;
120120
}
121121
// end-builder-lookup

0 commit comments

Comments
 (0)