Exemple #1
0
 /**
  * Validates value type
  *
  * @param mixed $value The value
  *
  * @return void
  *
  * @throws TypeException When value is an invalid type
  */
 private function guardValue($value)
 {
     if (!$this->isValid($value)) {
         $message = 'Value must be scalar or an array of scalars';
         throw TypeException::create($message);
     }
 }
Exemple #2
0
 /**
  * Validates monetary operand is an integer or float
  *
  * @param mixed $operand The operand
  *
  * @return void
  *
  * @throws TypeException When the operand is not an integer or float
  */
 private function guardOperand($operand)
 {
     if (!is_int($operand) && !is_float($operand)) {
         $message = sprintf('Operand must be an integer or float; received (%s) %s', gettype($operand), VarPrinter::toString($operand));
         throw TypeException::create($message);
     }
 }