Esempio n. 1
0
 private function assertInteger($integer, $throwable = null)
 {
     $throwable = ThrowableUtilities::validateAndNormalizeThrowable($throwable, new Exception\InvalidArgumentException('Argument must be an integer'));
     if (!is_int($integer)) {
         throw $throwable;
     }
 }
Esempio n. 2
0
 private function assertNotNull($notNull, $throwable = null)
 {
     $throwable = ThrowableUtilities::validateAndNormalizeThrowable($throwable, new Exception\InvalidArgumentException('Argument must not be null'));
     if ($notNull === null) {
         throw $throwable;
     }
 }
Esempio n. 3
0
 private function assertNotEmpty($notEmpty, $throwable = null)
 {
     $throwable = ThrowableUtilities::validateAndNormalizeThrowable($throwable, new Exception\InvalidArgumentException('Argument must not be empty'));
     if (empty($notEmpty)) {
         throw $throwable;
     }
 }
Esempio n. 4
0
 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;
     }
 }
Esempio n. 5
0
 private function assertNumeric($numeric, $throwable = null)
 {
     $throwable = ThrowableUtilities::validateAndNormalizeThrowable($throwable, new Exception\InvalidArgumentException('Argument must be numeric'));
     if (!is_numeric($numeric)) {
         throw $throwable;
     }
 }
Esempio n. 6
0
 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;
     }
 }