public static function is()

in src/Facebook/InstantArticles/Validators/Type.php [53:74]


    public static function is($var, $types_allowed, $enforce = false)
    {
        if (is_array($types_allowed)) {
            foreach ($types_allowed as $type) {
                if (($var instanceof $type) || self::isPrimitive($var, $type)) {
                    return true;
                }
            }
            if ($enforce) {
                self::throwException($var, $types_allowed);
            }
            return false;
        }

        $result = ($var instanceof $types_allowed) ||
            self::isPrimitive($var, $types_allowed);
        if (!$result && $enforce) {
            self::throwException($var, $types_allowed);
        }

        return $result;
    }