Example #1
0
 public function resolveCondition(ConditionJob $conditionJob, ExecutionContext $context)
 {
     $firstValueUnresolved = $conditionJob->getFirstParameter();
     $lastValueUnresolved = $conditionJob->getLastParameter();
     $firstValue = $this->resolveValue($firstValueUnresolved, $context);
     $lastValue = $this->resolveValue($lastValueUnresolved, $context);
     switch ($conditionJob->getOperator()) {
         case Operator::OP_ADDITION():
             return $firstValue + $lastValue;
         case Operator::OP_SUBTRACTION():
             return $firstValue - $lastValue;
         case Operator::OP_MULTIPLICATION():
             return $firstValue * $lastValue;
         case Operator::OP_DIVISION():
             return $firstValue / $lastValue;
         case Operator::OP_AND():
             return $firstValue && $lastValue;
         case Operator::OP_OR():
             return $firstValue || $lastValue;
         case Operator::OP_GREATER():
             return $firstValue > $lastValue;
         case Operator::OP_GREATEREQUAL():
             return $firstValue >= $lastValue;
         case Operator::OP_BETWEEN():
             return;
         case Operator::OP_NOT_BETWEEN():
             return;
         case Operator::OP_EQUAL():
             return $firstValue === $lastValue;
         case Operator::OP_NOT_EQUAL():
             return $firstValue !== $lastValue;
         case Operator::OP_EQUAL_NULLSAFE():
             return;
         case Operator::OP_LESSER():
             return $firstValue < $lastValue;
         case Operator::OP_LESSEREQUAL():
             return $firstValue <= $lastValue;
         case Operator::OP_LESSERGREATER():
             return true;
         case Operator::OP_IS():
             return $firstValue === $lastValue;
         case Operator::OP_IS_NOT():
             return $firstValue !== $lastValue;
         case Operator::OP_IS_NOT_NULL():
             return !is_null($firstValue);
         case Operator::OP_IS_NULL():
             return is_null($firstValue);
     }
 }