本文整理汇总了PHP中Elcodi\Component\Currency\Entity\Money::getCurrency方法的典型用法代码示例。如果您正苦于以下问题:PHP Money::getCurrency方法的具体用法?PHP Money::getCurrency怎么用?PHP Money::getCurrency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elcodi\Component\Currency\Entity\Money
的用法示例。
在下文中一共展示了Money::getCurrency方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validates the value to be greater or equal than the constraint value.
*
* @param Money $value Value
* @param Constraint $constraint Constraint
*
* @return null
*/
public function validate($value, Constraint $constraint)
{
if (null === $value) {
return null;
}
if (!$value instanceof Money) {
throw new UnexpectedTypeException($value, 'Elcodi\\Component\\Currency\\Entity\\Money');
}
$minimumMoney = Money::create($constraint->value, $value->getCurrency());
if ($value->isLessThan($minimumMoney)) {
$this->context->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value, self::OBJECT_TO_STRING))->setParameter('{{ compared_value }}', $this->formatValue($minimumMoney, self::OBJECT_TO_STRING))->setParameter('{{ compared_value_type }}', $this->formatTypeOf($minimumMoney))->addViolation();
}
}
示例2: testGetCurrency
/**
* @covers \Elcodi\Component\Currency\Entity\Money::getCurrency
*/
public function testGetCurrency()
{
$this->assertInstanceOf('\\Elcodi\\Component\\Currency\\Entity\\Currency', $this->oneHundredDollars->getCurrency());
}