Example #1
0
 /**
  * Returns the maximum of the given monies.
  *
  * If several monies are equal to the maximum value, the first one is returned.
  *
  * @param Money    $money  The first money.
  * @param Money ...$monies The subsequent monies.
  *
  * @return Money
  *
  * @throws CurrencyMismatchException If all the monies are not in the same currency.
  */
 public static function max(Money $money, Money ...$monies)
 {
     $max = $money;
     foreach ($monies as $money) {
         if ($money->isGreaterThan($max)) {
             $max = $money;
         }
     }
     return $max;
 }