Skip to content

Commit

Permalink
null check
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Schmidt committed Jul 25, 2018
1 parent a7c9ec3 commit e452acc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ulicms/classes/objects/abstract/Model.php
Expand Up @@ -77,6 +77,10 @@ public static function checkValueType($value, $type, $required = false)
throw new InvalidArgumentException("Required field not filled");
}
$isXyzFunction = "is_" . $type;
// if it's null and not required it's ok
if ($type === null) {
return;
}
if (function_exists($isXyzFunction) and ! $isXyzFunction($value)) {
throw new InvalidArgumentException("\"{$value}\" is not of type {$type}.");
} else if (class_exists($type) and $value instanceof $type) {
Expand Down

0 comments on commit e452acc

Please sign in to comment.