diff options
Diffstat (limited to 'vendor/doctrine/collections/src/Expr/ExpressionVisitor.php')
| -rw-r--r-- | vendor/doctrine/collections/src/Expr/ExpressionVisitor.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/vendor/doctrine/collections/src/Expr/ExpressionVisitor.php b/vendor/doctrine/collections/src/Expr/ExpressionVisitor.php new file mode 100644 index 0000000..afbd3d1 --- /dev/null +++ b/vendor/doctrine/collections/src/Expr/ExpressionVisitor.php | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Common\Collections\Expr; | ||
| 6 | |||
| 7 | use RuntimeException; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * An Expression visitor walks a graph of expressions and turns them into a | ||
| 11 | * query for the underlying implementation. | ||
| 12 | */ | ||
| 13 | abstract class ExpressionVisitor | ||
| 14 | { | ||
| 15 | /** | ||
| 16 | * Converts a comparison expression into the target query language output. | ||
| 17 | * | ||
| 18 | * @return mixed | ||
| 19 | */ | ||
| 20 | abstract public function walkComparison(Comparison $comparison); | ||
| 21 | |||
| 22 | /** | ||
| 23 | * Converts a value expression into the target query language part. | ||
| 24 | * | ||
| 25 | * @return mixed | ||
| 26 | */ | ||
| 27 | abstract public function walkValue(Value $value); | ||
| 28 | |||
| 29 | /** | ||
| 30 | * Converts a composite expression into the target query language output. | ||
| 31 | * | ||
| 32 | * @return mixed | ||
| 33 | */ | ||
| 34 | abstract public function walkCompositeExpression(CompositeExpression $expr); | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Dispatches walking an expression to the appropriate handler. | ||
| 38 | * | ||
| 39 | * @return mixed | ||
| 40 | * | ||
| 41 | * @throws RuntimeException | ||
| 42 | */ | ||
| 43 | public function dispatch(Expression $expr) | ||
| 44 | { | ||
| 45 | return match (true) { | ||
| 46 | $expr instanceof Comparison => $this->walkComparison($expr), | ||
| 47 | $expr instanceof Value => $this->walkValue($expr), | ||
| 48 | $expr instanceof CompositeExpression => $this->walkCompositeExpression($expr), | ||
| 49 | default => throw new RuntimeException('Unknown Expression ' . $expr::class), | ||
| 50 | }; | ||
| 51 | } | ||
| 52 | } | ||
