コード例 #1
0
ファイル: CurrencyType.php プロジェクト: novuso/common-bundle
 /**
  * Converts a value from its database representation to its PHP representation
  *
  * @param mixed            $value    The value to convert
  * @param AbstractPlatform $platform The currently used database platform
  *
  * @return mixed
  *
  * @throws ConversionException When the conversion fails
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if (empty($value)) {
         return null;
     }
     if ($value instanceof Currency) {
         return $value;
     }
     try {
         $currency = Currency::fromValue($value);
     } catch (Exception $exception) {
         throw ConversionException::conversionFailed($value, static::TYPE_NAME);
     }
     return $currency;
 }
コード例 #2
0
ファイル: Money.php プロジェクト: novuso/common
 /**
  * Checks whether other money has the same currency
  *
  * @param Money $other The other monetary value
  *
  * @return bool
  */
 public function isSameCurrency(Money $other) : bool
 {
     return $this->currency->equals($other->currency);
 }
コード例 #3
0
ファイル: CurrencyTest.php プロジェクト: novuso/common-l
 public function test_that_minor_returns_expected_value()
 {
     $currency = Currency::IQD();
     $this->assertSame(1000, $currency->minor());
 }