original_string: public function calculate($values)
      {
          $dataToReplace = array();
          foreach ($this->getVariables() as $mask => $var) {
              $var = $values[$var];
              if ($var instanceof \DateTime) {
                  $var = new \Zend_Date($var->getTimestamp());
                  $var = $var->get(self::DEFAULT_DATETIME_MASK);
              }
              $dataToReplace[$mask] = $var;
          }
          $condition = str_replace(array_keys($dataToReplace), array_values($dataToReplace), $this->condition);
          $condition = explode($this->operator, $condition);
          if (is_numeric($condition[0])) {
              $condition[0] = floatval($condition[0]);
          } else {
              $condition[0] = trim($condition[0]);
          }
          if (is_numeric($condition[1])) {
              $condition[1] = floatval($condition[1]);
          } else {
              $condition[1] = trim($condition[1]);
          }
          $out = null;
          switch ($this->operator) {
              case self::OPERATOR_EQ:
                  $out = $condition[0] == $condition[1];
                  break;
              case self::OPERATOR_NEQ:
                  $out = $condition[0] != $condition[1];
                  break;
              case self::OPERATOR_GRATER:
                  $out = $condition[0] > $condition[1];
                  break;
              case self::OPERATOR_GRATER_EQ:
                  $out = $condition[0] >= $condition[1];
                  break;
              case self::OPERATOR_LESS:
                  $out = $condition[0] < $condition[1];
                  break;
              case self::OPERATOR_LESS_EQ:
                  $out = $condition[0] <= $condition[1];
                  break;
              default:
                  throw new Exception\UnknownPairOperatorException('Operator "' . $this->operator . '" is not supported.');
          }
          return $out;
      }
code: public function calculate($values)
      {
          $dataToReplace = array();
          foreach ($this->getVariables() as $mask => $var) {
              $var = $values[$var];
              if ($var instanceof \DateTime) {
                  $var = new \Zend_Date($var->getTimestamp());
                  $var = $var->get(self::DEFAULT_DATETIME_MASK);
              }
              $dataToReplace[$mask] = $var;
          }
          $condition = str_replace(array_keys($dataToReplace), array_values($dataToReplace), $this->condition);
          $condition = explode($this->operator, $condition);
          if (is_numeric($condition[0])) {
              $condition[0] = floatval($condition[0]);
          } else {
              $condition[0] = trim($condition[0]);
          }
          if (is_numeric($condition[1])) {
              $condition[1] = floatval($condition[1]);
          } else {
              $condition[1] = trim($condition[1]);
          }
          $out = null;
          switch ($this->operator) {
              case self::OPERATOR_EQ:
                  $out = $condition[0] == $condition[1];
                  break;
              case self::OPERATOR_NEQ:
                  $out = $condition[0] != $condition[1];
                  break;
              case self::OPERATOR_GRATER:
                  $out = $condition[0] > $condition[1];
                  break;
              case self::OPERATOR_GRATER_EQ:
                  $out = $condition[0] >= $condition[1];
                  break;
              case self::OPERATOR_LESS:
                  $out = $condition[0] < $condition[1];
                  break;
              case self::OPERATOR_LESS_EQ:
                  $out = $condition[0] <= $condition[1];
                  break;
              default:
                  throw new Exception\UnknownPairOperatorException('Operator "' . $this->operator . '" is not supported.');
          }
          return $out;
      }
code_tokens: public function calculate ( $ values ) { $ dataToReplace = array ( ) ; foreach ( $ this -> getVariables ( ) as $ mask => $ var ) { $ var = $ values [ $ var ] ; if ( $ var instanceof \ DateTime ) { $ var = new \ Zend_Date ( $ var -> getTimestamp ( ) ) ; $ var = $ var -> get ( self :: DEFAULT_DATETIME_MASK ) ; } $ dataToReplace [ $ mask ] = $ var ; } $ condition = str_replace ( array_keys ( $ dataToReplace ) , array_values ( $ dataToReplace ) , $ this -> condition ) ; $ condition = explode ( $ this -> operator , $ condition ) ; if ( is_numeric ( $ condition [ 0 ] ) ) { $ condition [ 0 ] = floatval ( $ condition [ 0 ] ) ; } else { $ condition [ 0 ] = trim ( $ condition [ 0 ] ) ; } if ( is_numeric ( $ condition [ 1 ] ) ) { $ condition [ 1 ] = floatval ( $ condition [ 1 ] ) ; } else { $ condition [ 1 ] = trim ( $ condition [ 1 ] ) ; } $ out = null ; switch ( $ this -> operator ) { case self :: OPERATOR_EQ : $ out = $ condition [ 0 ] == $ condition [ 1 ] ; break ; case self :: OPERATOR_NEQ : $ out = $ condition [ 0 ] != $ condition [ 1 ] ; break ; case self :: OPERATOR_GRATER : $ out = $ condition [ 0 ] > $ condition [ 1 ] ; break ; case self :: OPERATOR_GRATER_EQ : $ out = $ condition [ 0 ] >= $ condition [ 1 ] ; break ; case self :: OPERATOR_LESS : $ out = $ condition [ 0 ] < $ condition [ 1 ] ; break ; case self :: OPERATOR_LESS_EQ : $ out = $ condition [ 0 ] <= $ condition [ 1 ] ; break ; default : throw new Exception \ UnknownPairOperatorException ( 'Operator "' . $ this -> operator . '" is not supported.' ) ; } return $ out ; }
docstring: Calculating condition by given values.
  
  @param array $values
  
  @throws Exception\UnknownPairOperatorException
  @return boolean
docstring_tokens: Calculating condition by given values .