Ejemplo n.º 1
0
 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));
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 public function setUp()
 {
     Currency::$currencyPrecisions = (include __DIR__ . "/../precisions.php");
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }