Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 16 |
| ExpressionVisitor | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
56 | |
0.00% |
0 / 16 |
| walkComparison(Comparison $comparison) | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| walkValue(Value $value) | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| walkCompositeExpression(CompositeExpression $expr) | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| dispatch(Expression $expr) | |
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 13 |
|||
| <?php | |
| // Copyright (c) Lellys Informática. All rights reserved. See License.txt in the project root for license information. | |
| namespace Easy\Collections\Linq\Expr; | |
| /** | |
| * An Expression visitor walks a graph of expressions and turns them into a | |
| * query for the underlying implementation. | |
| * | |
| * @author Benjamin Eberlei <kontakt@beberlei.de> | |
| */ | |
| abstract class ExpressionVisitor | |
| { | |
| /** | |
| * Converts a comparison expression into the target query language output. | |
| * | |
| * @param Comparison $comparison | |
| * | |
| * @return mixed | |
| */ | |
| abstract public function walkComparison(Comparison $comparison); | |
| /** | |
| * Converts a value expression into the target query language part. | |
| * | |
| * @param Value $value | |
| * | |
| * @return mixed | |
| */ | |
| abstract public function walkValue(Value $value); | |
| /** | |
| * Converts a composite expression into the target query language output. | |
| * | |
| * @param CompositeExpression $expr | |
| * | |
| * @return mixed | |
| */ | |
| abstract public function walkCompositeExpression(CompositeExpression $expr); | |
| /** | |
| * Dispatches walking an expression to the appropriate handler. | |
| * | |
| * @param Expression $expr | |
| * | |
| * @return mixed | |
| * | |
| * @throws \RuntimeException | |
| */ | |
| public function dispatch(Expression $expr) | |
| { | |
| switch (true) { | |
| case ($expr instanceof Comparison): | |
| return $this->walkComparison($expr); | |
| case ($expr instanceof Value): | |
| return $this->walkValue($expr); | |
| case ($expr instanceof CompositeExpression): | |
| return $this->walkCompositeExpression($expr); | |
| default: | |
| throw new \RuntimeException("Unknown Expression " . get_class($expr)); | |
| } | |
| } | |