Ejemplo n.º 1
0
 /**
  * Assert that current and given money objects have same currencies.
  *
  * @param  \NetTeam\DDD\ValueObject\Money $other
  * @throws \DomainException
  */
 private function assertSameCurrency(Money $other)
 {
     if ($this->currency() !== $other->currency()) {
         throw new \DomainException(sprintf('Money object must have same currencies, current is %s and given %s', $this->currency(), $other->currency()));
     }
 }
Ejemplo n.º 2
0
 public function testConstructionWithStringValueAndCurrency()
 {
     $money = new Money('123.45', 'USD');
     $this->assertEquals(123.45, $money->amount());
     $this->assertEquals('USD', $money->currency());
 }