本文整理匯總了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());
}