コード例 #1
0
/**
 * Converts a Money value object to a string for the database reporting etc
 * @param \SebastianBergmann\Money\Money $value
 * @return string
 */
function convertMoneyToString(Money $value)
{
    return convertIntToString($value->getAmount(), $value->getCurrency());
}
コード例 #2
0
ファイル: IntlFormatter.php プロジェクト: erictho/money
 /**
  * Formats a Money object using PHP's built-in NumberFormatter.
  *
  * @param  \SebastianBergmann\Money\Money $money
  * @return string
  */
 public function format(Money $money)
 {
     return $this->numberFormatter->formatCurrency($money->getAmount() / $money->getCurrency()->getSubUnit(), $money->getCurrency()->getCurrencyCode());
 }
コード例 #3
0
ファイル: Money.php プロジェクト: Aerendir/PHPValueObjects
 /**
  * {@inheritdoc}
  */
 public function getAmount()
 {
     return $this->valueObject->getAmount();
 }
コード例 #4
0
ファイル: ValueTrait.php プロジェクト: harp-orm/money
 /**
  * @return static
  */
 public function setValue(Money $value)
 {
     $this->value = $value->getAmount();
     return $this;
 }
コード例 #5
0
 /**
  * The value "exists" if it is not 0
  * @return bool
  */
 public function exists()
 {
     return $this->value->getAmount() !== 0;
 }
コード例 #6
0
 /**
  * @param  Money    $money
  * @param  Currency $to
  * @param  int      $roundingMode
  * @return Money
  */
 public function convert(Money $money, Currency $to, $roundingMode = PHP_ROUND_HALF_UP)
 {
     $new = new Money($money->getAmount(), $to);
     $conversionRate = $this->source->getRateBetween($money->getCurrency(), $to);
     return $new->multiply($conversionRate, $roundingMode);
 }