/** * @param JBCartValue $value * @param string|int|float|JBCartValue $mode * @param integer $round * @return bool */ public function compare($value, $mode = '==', $round = self::ROUND_DEFAULT) { if (!$value instanceof JBCartValue) { $value = new JBCartValue($value); } $mode = in_array($mode, array('=', '==', '===')) ? '==' : $mode; $round = is_null($round) ? self::ROUND_DEFAULT : (int) $round; $val1 = round((double) $this->val($this->_currency), $round); $val2 = round((double) $value->val($this->_currency), $round); $this->_log("Compared \"{$this->dump()}\" {$mode} \"{$value->dump()}\" // {$val1}{$mode}{$val2}, r={$round}, "); if ($mode == '==') { return $val1 === $val2; } else { if ($mode == '!=' || $mode == '!==') { return $val1 !== $val2; } else { if ($mode == '<') { return $val1 < $val2; } else { if ($mode == '>') { return $val1 > $val2; } else { if ($mode == '<=') { return $val1 <= $val2; } else { if ($mode == '>=') { return $val1 >= $val2; } } } } } } $this->_error('Undefined compare mode: ' . $mode); return false; }