コード例 #1
0
ファイル: Accountant.php プロジェクト: browner12/money
 /**
  * compare
  *
  * tell user if $money1 is less than (-1), greater than (1), or equal to (0) $money2
  *
  * @param \browner12\money\Money $money1
  * @param \browner12\money\Money $money2
  * @return int
  */
 public function compare(Money $money1, Money $money2)
 {
     //check currencies
     $this->isSameCurrency([$money1, $money2]);
     //equal to
     if ($money1->subunits() == $money2->subunits()) {
         return 0;
     }
     //greater than or less than
     return $money1->subunits() > $money2->subunits() ? 1 : -1;
 }