|
|
@@ -23,6 +23,20 @@ class VariableHelper
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Checks if variable is instance of className. Throws exception if not
|
|
|
+ * @param mixed $variable
|
|
|
+ * @param string $className
|
|
|
+ * @param string $message
|
|
|
+ * @throws InvalidConfigException
|
|
|
+ */
|
|
|
+ public static function isInstanceOf($variable, $className, $message = null)
|
|
|
+ {
|
|
|
+ if (!($variable instanceof $className)) {
|
|
|
+ throw new InvalidConfigException($message, sprintf('Variable must be instance of class %s', $className));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Checks if variable is null and throws InvalidConfigException if it is null
|
|
|
* @param mixed $variable variable to check
|