/** * 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); } }
/** * 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); } }