Exemplo n.º 1
0
 /**
  * Extract a money object into an array converting the integer amount to a float
  * @param  Money                              $object
  * @return array
  * @throws Exception\InvalidArgumentException
  */
 public function extract($object)
 {
     if (!$object instanceof Money) {
         throw new Exception\InvalidArgumentException(sprintf('%s expects a Money instance', __METHOD__));
     }
     $subUnit = $object->getCurrency()->getSubUnit();
     $amount = (double) ($object->getAmount() / $subUnit);
     return array('amount' => $amount, 'currency' => $object->getCurrencyCode());
 }
Exemplo n.º 2
0
 /**
  * @covers  \NetglueMoney\Money\Money::getCurrencyCode
  * @uses    \NetglueMoney\Money\Currency
  * @depends testObjectCanBeConstructedForValidConstructorArguments
  */
 public function testCurrencyCodeCanBeRetrieved(Money $m)
 {
     $this->assertEquals('EUR', $m->getCurrencyCode());
 }