示例#1
0
 /**
  * compare
  * 
  * Compares two instances for equality. Returns a value suitable for a sort
  * callback. i.e. 1 if $first is larger than $second, 0 if equal, and -1 if
  * $first is smaller than $second.
  * 
  * @param Money $first
  * @param Money $second
  * @return int -1, 0, or 1
  */
 public function compare(Money $first, Money $second)
 {
     $secondValue = $first->getCurrency()->getCode() === $second->getCurrency()->getCode() ? $second->getValue() : $this->converter->convert($second, $first->getCurrency())->getValue();
     return bccomp($first->getValue(), $secondValue, max([$first->getPrecision(), $second->getPrecision()]));
 }