public function testEqualButNotSame() { $eur1 = new Currency("EUR", 5); $eur2 = new Currency("EUR", 10); $this->assertTrue($eur1->isEqualTo($eur2)); $this->assertTrue($eur2->isEqualTo($eur1)); $this->assertFalse($eur1->isSameTo($eur2)); $this->assertFalse($eur2->isSameTo($eur1)); }
/** * Sets the amount considering precision of the currency. * * @param numeric $amount */ protected function setAmount($amount) { if (!is_numeric($amount)) { throw new InvalidArgumentException("Amount must be a numeric value"); } $precision = $this->currency->getPrecision(); $amount = round($amount, $precision); if (0 === $precision) { $amount = (int) $amount; } $this->amount = $amount; }
public function setUp() { Currency::$currencyPrecisions = (include __DIR__ . "/../precisions.php"); }
/** * Checks if the Currency is equal to the given one * * @param Currency $other * * @return boolean */ public function isEqualTo(Currency $other) { return $other->getCode() === $this->code; }