private function assertInteger($integer, $throwable = null) { $throwable = ThrowableUtilities::validateAndNormalizeThrowable($throwable, new Exception\InvalidArgumentException('Argument must be an integer')); if (!is_int($integer)) { throw $throwable; } }
private function assertNotNull($notNull, $throwable = null) { $throwable = ThrowableUtilities::validateAndNormalizeThrowable($throwable, new Exception\InvalidArgumentException('Argument must not be null')); if ($notNull === null) { throw $throwable; } }
private function assertNotEmpty($notEmpty, $throwable = null) { $throwable = ThrowableUtilities::validateAndNormalizeThrowable($throwable, new Exception\InvalidArgumentException('Argument must not be empty')); if (empty($notEmpty)) { throw $throwable; } }
private function assertScalar($scalar, $throwable = null) { $throwable = ThrowableUtilities::validateAndNormalizeThrowable($throwable, new Exception\InvalidArgumentException('Argument must be a scalar value')); if (!is_scalar($scalar)) { throw $throwable; } }
private function assertNumeric($numeric, $throwable = null) { $throwable = ThrowableUtilities::validateAndNormalizeThrowable($throwable, new Exception\InvalidArgumentException('Argument must be numeric')); if (!is_numeric($numeric)) { throw $throwable; } }
private function assertString($string, $throwable = null, $allowObjects = true) { $throwable = ThrowableUtilities::validateAndNormalizeThrowable($throwable, new Exception\InvalidArgumentException('Argument must be a string')); if ($allowObjects && is_object($string) && method_exists($string, '__toString')) { return; } if (!is_string($string)) { throw $throwable; } }