Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit 745eef4

Browse files
committed
Introduce dedicated interface for branches in $switch
1 parent a1eb7b6 commit 745eef4

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

generator/config/expression/case.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: $case
33
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/'
44
type:
5-
- resolvesToAny
5+
- switchBranch
66
encode: flat_object
77
description: |
88
Represents a single case in a $switch expression

generator/config/expressions.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@
113113
'returnType' => Type\GeometryInterface::class,
114114
'acceptedTypes' => [Type\GeometryInterface::class, ...$bsonTypes['object']],
115115
],
116+
'switchBranch' => [
117+
'returnType' => Type\SwitchBranchInterface::class,
118+
'acceptedTypes' => [Type\SwitchBranchInterface::class, ...$bsonTypes['object']],
119+
],
116120

117121
// @todo add enum values
118122
'Granularity' => [

generator/config/schema.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"filter",
3030
"window",
3131
"geometry",
32+
"switchBranch",
3233
"resolvesToAny",
3334
"resolvesToNumber",
3435
"resolvesToDouble",

src/Builder/Expression/CaseOperator.php

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MongoDB\Builder\Type;
6+
7+
/**
8+
* Interface for branches in $switch operators
9+
*
10+
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/
11+
*/
12+
interface SwitchBranchInterface
13+
{
14+
}

0 commit comments

Comments
 (0)