public static function validate($argument, $types = [], $throwException = true)
    {
        $valid = false;
        foreach ($types as $type) {
            if (strcasecmp(gettype($argument), $type) == 0) {
                $valid = true;
                break;
            }
        }
        if (!$valid && $throwException) {
            throw new \InvalidArgumentException(implode(" or ", $types) . " required. " . gettype($argument) . " given.");
        }
        return $valid;
    }