Exemple #1
0
 protected function areConditionsValid(Transaction $transaction, Rule $rule)
 {
     if ($transaction->isProcessed()) {
         return false;
     }
     $isValid = true;
     $firstCondition = true;
     foreach ($rule->getConditions() as $condition) {
         $conditionClass = $this->factory->getConditionClass($condition->getCondition());
         $conditionIsValid = $conditionClass->checkCondition($transaction, $condition);
         if ($firstCondition) {
             $isValid = $conditionIsValid ? true : false;
             $firstCondition = false;
         } elseif ($condition->getConditionLink() == 'OR') {
             if ($isValid || $conditionIsValid) {
                 $isValid = true;
             } else {
                 $isValid = false;
             }
         } else {
             if ($isValid && $conditionIsValid) {
                 $isValid = true;
             } else {
                 $isValid = false;
             }
         }
     }
     return $isValid;
 }