protected function getParsedConfig(array $config, array $existingConfig, array $configMap, array $required)
    {
        $parsedConfig = [];

        foreach ($config as $key => $value) {
            $cfgKey = strtolower($key);
            if (!isset($configMap[$cfgKey])) {
                throw new ConfigurationException(
                    sprintf('Option "%s" not recognized.', $key)
                );
            }
            $parsedConfig[$configMap[$cfgKey]] = $value;
        }

        if (!$this->isParsedConfigValid($parsedConfig, $required)) {
            $needed = [];
            foreach ($required as $option) {
                $needed[] = array_search($option, $configMap);
            }
            throw new ConfigurationException(
                sprintf('Some required configuration options are missing. Required: %s', implode(', ', $needed))
            );
        }
        $existingConfig = array_merge($existingConfig, $parsedConfig);

        return array_filter($existingConfig, function ($v) {
            return $v !== null && $v !== '';
        });
    }