Пример #1
0
 protected function evaluate($value) {
     if ($value === null) {
         $value = 0;
     }
     switch ($this->rule->getEquation()) {
         case Pap_Features_PerformanceRewards_Condition::EQUATION_BETWEEN :
             Gpf_log::info('Rule condition: '.$value.' BETWEEN '.$this->rule->getEquationValue1().' and '.$this->rule->getEquationValue2());
             if ($this->rule->getEquationValue1() < $value && $value < $this->rule->getEquationValue2()) {
                 return true;
             }
             break;
         case Pap_Features_PerformanceRewards_Condition::EQUATION_EQUAL_TO :
             Gpf_log::info('Rule condition: '.$value.' EQUAL TO '.$this->rule->getEquationValue1());
             if ($this->rule->getEquationValue1() == $value) {
                 return true;
             }
             break;
         case Pap_Features_PerformanceRewards_Condition::EQUATION_HIGHER_THAN :
             Gpf_log::info('Rule condition: '.$value.' HIGHER THAN '.$this->rule->getEquationValue1());
             if ($this->rule->getEquationValue1() < $value) {
                 return true;
             }
             break;
         case Pap_Features_PerformanceRewards_Condition::EQUATION_LOWER_THAN :
             Gpf_log::info('Rule condition: '.$value.' LOWER THAN '.$this->rule->getEquationValue1());
             if ($this->rule->getEquationValue1() > $value) {
                 return true;
             }
             break;
         default : throw new Gpf_Exception('Unsupported equation');
     }
     return false;
 }