LdapTools\ConfigurationParseTrait::getParsedConfig PHP Метод

getParsedConfig() защищенный Метод

Parses a YAML config section and sends it back as the correct config values as an array.
protected getParsedConfig ( array $config, array $existingConfig, array $configMap, array $required ) : array
$config array The YAML config section as an array.
$existingConfig array The config before merging the YAML config.
$configMap array The YAML to config key map array.
$required array The required options that must be in the array.
Результат array The YAML config merged with the existing config.
    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 !== '';
        });
    }