Ensures that the two Price instances have the same currency.

@param \CommerceGuys\Pricing\Price $a
@param \CommerceGuys\Pricing\Price $b

@throws \CommerceGuys\Pricing\CurrencyMismatchException
547698
protected function assertSameCurrency(Price $a, Price $b)
    {
        if ($a->getCurrency() != $b->getCurrency()) {
            throw new CurrencyMismatchException;
        }
    }
293123
private function swap($a, $b) {
        $value            = $this->values[$a];
        $this->values[$a] = $this->values[$b];
        $this->values[$b] = $value;
    }
999149
protected function updateCurrency(Money $money): self
    {
        if ($this->currency && $money->getCurrency()->getCode() !== $this->currency) {
            throw new CurrencyMismatchException('The currency on this stock movement is not the same as the one your Money object');
        }

        $this->currency = $money->getCurrency()->getCode();

        return $this;
    }
1155253
public function compare(DecimalNumber $a, DecimalNumber $b)
    {
        if (function_exists('bccomp')) {
            return $this->compareUsingBcMath($a, $b);
        }

        return $this->compareWithoutBcMath($a, $b);
    }
241795
public function setUnitPrice(Money $unitPrice): PriceInterface
    {
        // @todo change type from int to string
        $this->unitPrice = (int) $unitPrice->getAmount();

        return $this;
    }
948789
public function compare(Money $other)
    {
        $this->assertSameCurrency($other);

        return $this->getCalculator()->compare($this->amount, $other->amount);
    }
781224
public function setPrice($price, $currency, $type = null, $resolution = null)
    {
        self::$xml['price'] .= VideoItemPriceTags::setPrice($this->validator, $price, $currency, $type, $resolution);

        return $this;
    }
938006
function sameValueZero(a, b) {
    if (isRealNaN(a)) {
      return isRealNaN(b);
    }
    return a === b ? a !== 0 || 1 / a === 1 / b : false;
  }
459441
public function setCurrency($currency)
    {
      if(!is_string($currency) || strlen(trim($currency)) == 0)
        throw new InvalidArgumentException(__METHOD__ . '; Invalid currency, must be a non empty string');

      $this->currency = $currency;
    }
1115535
public function formatPrice($price)
    {
        $currencies = new ISOCurrencies();

        $numberFormatter = new \NumberFormatter($this->locale, \NumberFormatter::CURRENCY);
        $moneyFormatter = new IntlMoneyFormatter($numberFormatter, $currencies);

        return $moneyFormatter->format($price);
    }
379896
private function _checkCurrency(&$currency)
    {
        if (!isset($currency)) {
            throw new Klarna_ArgumentNotSetException("Currency");
        }
        if (is_numeric($currency) && !is_int($currency)) {
            $currency = intval($currency);
        }
        if (!is_numeric($currency) || !is_int($currency)) {
            throw new Klarna_InvalidTypeException("Currency", "integer");
        }
    }
211958
static MonetaryAmount max(MonetaryAmount a, MonetaryAmount b) {
        MoneyUtils.checkAmountParameter(Objects.requireNonNull(a), Objects.requireNonNull(b.getCurrency()));
        return a.isGreaterThan(b) ? a : b;
    }
1228256
public function subtract(Money $money)
    {
        if (!$this->currency->equals($money->getCurrency())) {
            throw new CurrencyMismatchException($this.' does not match '.$money);
        }

        $amount = bcsub($this->amount, $money->getAmount(), self::BCSCALE);

        return self::valueOf($amount, $this->currency);
    }
348706
protected function setPrice(array &$data)
    {
        if (!empty($data['price']) && !empty($data['currency'])) {
            $data['price'] = $this->price->amount($data['price'], $data['currency']);
        }
    }
462599
public function findPriceByCurrency($currency): ?PriceInterface
    {
        if ($currency instanceof \Money\Currency) {
            $currency = $currency->getCode();
        } elseif ($currency instanceof CurrencyInterface) {
            $currency = $currency->getIsoCodeAlpha();
        }

        if (!is_string($currency)) {
            throw new \InvalidArgumentException('$currency has to be a string');
        }

        foreach ($this->prices as $price) {
            if ($price->getCurrency()->getIsoCodeAlpha() === $currency) {
                return $price;
            }
        }

        return null;
    }
311503
public static function compare($price1, $price2)
    {
        //====================================================================//
        // Check Both Prices are valid
        if (!self::isValid($price1) || !self::isValid($price2)) {
            Splash::log()->war(__FUNCTION__." : Given Prices are invalid");
            if (!self::isValid($price1)) {
                Splash::log()->www(__FUNCTION__." Price 1", $price1);
            }
            if (!self::isValid($price2)) {
                Splash::log()->www(__FUNCTION__." Price 2", $price2);
            }

            return false;
        }
        //====================================================================//
        // Compare Base Price
        if (((bool) $price1["base"]) != ((bool) $price2["base"])) {
            return false;
        }
        //====================================================================//
        // Compare Price
        return self::compareAmounts($price1, $price2);
    }
784901
protected static function compareZone(DateTime $a, DateTime $b) {
        if (false === DateTimeZoneHelper::equals($a->getTimezone(), $b->getTimezone())) {
            throw new IllegalArgumentException("The two date/times does not have the same time zone");
        }
    }