private static function validateOptions(array $options)
    {
        foreach ($options as $key => $value) {
            if (!isset(self::$types[$key])) {
                throw new \DomainException("Unknown option: $key");
            }
            if ($key === 'autoschedule' && !defined('CURLMOPT_MAX_TOTAL_CONNECTIONS')) {
                throw new \OutOfBoundsException('"autoschedule" can be used only on PHP 7.0.7 or later.');
            }
            $validator = [__CLASS__, 'validate' . self::$types[$key]];
            $options[$key] = $validator($key, $value);
        }
        return $options;
    }