/**
  * Return counted expression accorded parsed string
  *
  * @param string $expr
  * @param Varien_Data_Collection $collection
  * @return float|int
  */
 protected function _countExpr($expr, $collection)
 {
     $parsedExpression = $this->_parser->parseExpression($expr);
     $result = $tmpResult = 0;
     $firstOperand = $secondOperand = null;
     foreach ($parsedExpression as $operand) {
         if ($this->_parser->isOperation($operand)) {
             $this->_checkOperandsSet($firstOperand, $secondOperand, $tmpResult, $result);
             $result = $this->_operate($firstOperand, $secondOperand, $operand, $tmpResult, $result);
             $firstOperand = $secondOperand = null;
         } else {
             if (null === $firstOperand) {
                 $firstOperand = $this->_checkOperand($operand, $collection);
             } elseif (null === $secondOperand) {
                 $secondOperand = $this->_checkOperand($operand, $collection);
             }
         }
     }
     return $result;
 }
Exemple #2
0
 /**
  * @param $operation
  * @param $expected
  * @dataProvider isOperationDataProvider
  */
 public function testIsOperation($operation, $expected)
 {
     $this->assertEquals($expected, $this->_model->isOperation($operation));
 }