コード例 #1
0
ファイル: Integer.php プロジェクト: kdyby/money
 /**
  * @param self|int|string|float $arg
  * @throws InvalidArgumentException
  * @return int|float
  */
 protected function valueToNumber($arg)
 {
     if ($arg instanceof self) {
         return $arg->toInt();
     }
     return Math::parseNumber($arg);
 }
コード例 #2
0
ファイル: Money.php プロジェクト: pilec/Money
 protected function valueToNumber($arg)
 {
     if ($arg instanceof Money && !$arg->currency->isInterchangeable($this->currency)) {
         throw new InvalidArgumentException("Currency {$arg->currency} is not compatible with {$this->currency}.");
     }
     return parent::valueToNumber($arg);
 }