Extracts targets from configuration.

@param array $config
@return array
@throws \DomainException if targets setting is invalid
499506
protected function getTargets(array $config)
    {
        if (!isset($config['targets'])
            || !is_array($config['targets'])
            || array_filter($config['targets'], 'is_array') != $config['targets']) {
            throw new \DomainException(
                'targets must be an array of arrays',
                self::ERR_TARGETS_INVALID
            );
        }
        return $config['targets'];
    }
599909
protected function buildFilters(array $config)
    {
        $filters = [];

        foreach ((isset($config['filters']) ? $config['filters'] : []) as $name => $filter) {
            $filter = $this->buildFilter(array_merge(['name' => $name], $filter), $config);
            $filters[$filter->getName()] = $filter;
        }

        return $filters;
    }
419463
protected function getDsn(array $config)
    {
        extract($config);

        // First we will create the basic DSN setup as well as the port if it is in
        // in the configuration options. This will give us the basic DSN we will
        // need to establish the PDO connections and return them back for use.
        if (in_array('dblib', $this->getAvailableDrivers())) {
            $port = isset($config['port']) ? ':'.$port : '';

            return "dblib:host={$hostname}{$port};dbname={$database}";
        }

        $port = isset($config['port']) ? ','.$port : '';

        $dbName = $database != '' ? ";Database={$database}" : '';

        return "sqlsrv:Server={$hostname}{$port}{$dbName}";
    }
27623
public function getConfigDefaultSections(Config $config)
    {
        $index = spl_object_hash($config);
        $default_sections = [];
        if (true === array_key_exists($index, $this->configsDefaultSections)) {
            $default_sections = $this->configsDefaultSections[$index];
        }

        return $default_sections;
    }
182483
public function config(array $config)
    {
        $this->validateConfig($config);


        if (array_key_exists('location', $config)) {
            $this->defaults->setLocation($config['location']);
        }

        if (array_key_exists('port', $config)) {
            $this->defaults->setPort($config['port']);
        }

        if (array_key_exists('headers', $config)) {
            $this->defaults->setHeaders($config['headers']);
        }

        if (array_key_exists('credentials', $config)) {
            $this->defaults->setCredentials(
                array_get($config['credentials'], 'name'),
                array_get($config['credentials'], 'password'),
                array_get($config['credentials'], 'domain')
            );
        }

        if (array_key_exists('method', $config)) {
            $this->defaults->setMethod($config['method']);
        }

        if (array_key_exists('parameters', $config)) {
            $this->defaults->setParameters($config['parameters']);
        }

        if (array_key_exists('body', $config)) {
            $this->defaults->setBody($config['body']);
        }

        if (array_key_exists('options', $config)) {
            $this->defaults->setOptions($config['options']);
        }

        return $this;
    }
808380
private function getAllFiles(Config $config)
    {
        $file_extensions = $config->getFileExtensions();
        $file_paths = [];

        foreach ($config->getProjectDirectories() as $dir_name) {
            $file_paths = array_merge(
                $file_paths,
                $this->file_provider->getFilesInDir($dir_name, $file_extensions)
            );
        }

        return $file_paths;
    }
1090951
protected function parseConfig($config)
    {
        $parsed = [];

        foreach ($config as $key=>$value) {
            if ($value instanceof XType) {
                $parsed[$key] = $value;
                continue;
            }
            $parsed[$key] = $this->stringToType($value);
        }

        return $parsed;
    }
1179842
private function getConfigsForUriTemplates($config)
    {
        $configs = [$config];

        if ($config['additionalBindings']) {
            foreach ($config['additionalBindings'] as $additionalBinding) {
                $configs[] = $additionalBinding + $config;
            }
        }

        return $configs;
    }
139414
protected function getPlugins(array $config)
    {
        if (!isset($config['plugins']) || !is_array($config['plugins'])) {
            throw new \RuntimeException(
                'Configuration must contain "plugins" key referencing an array',
                self::ERR_PLUGINS_NONARRAY
            );
        }

        $filtered = array_filter(
            $config['plugins'],
            function($plugin) {
                return !$plugin instanceof PluginInterface;
            }
        );
        if ($filtered) {
            throw new \RuntimeException(
                'Configuration "plugins" key must contain only objects'
                    . ' implementing \Phergie\Irc\Bot\React\PluginInterface',
                self::ERR_PLUGINS_NONPLUGINS
            );
        }

        return $config['plugins'];
    }
315558
protected function getOptions(array $config)
    {
        $options = [];

        if ($visibility = array_get($config, 'visibility')) {
            $options['visibility'] = $visibility;
        }

        if ($pirate = array_get($config, 'pirate')) {
            $options['disable_asserts'] = $pirate;
        }

        return $options;
    }
1140096
private function databaseFilter(array $config)
    {
        return [
            'driver'   => isset($config['driver'])   ? $config['driver']   : '',
            'name'     => isset($config['dbname'])   ? $config['dbname']   : '',
            'user'     => isset($config['user'])     ? $config['user']     : '',
            'password' => isset($config['password']) ? $config['password'] : '',
        ];
    }
860298
protected function buildHandlers(array $config):array
    {
        $handlers = [];
        foreach ($config as $handler) {
            $level = constant('\Mostofreddy\Loggy\Logger::'. strtoupper($handler['level']));
            $handlerObj = '\Mostofreddy\Loggy\Handler\\'.ucfirst($handler['handler']);
            $handlers[] = (new $handlerObj($level))->config($handler);
        }
        return $handlers;
    }
59475
protected function getFormatter(array $config)
    {
        if (isset($config['formatter'])) {
            if (!$config['formatter'] instanceof FormatterInterface) {
                throw new \DomainException(
                    'formatter must implement ' . __NAMESPACE__ . '\FormatterInterface',
                    self::ERR_FORMATTER_INVALID
                );
            }
            return $config['formatter'];
        }
        return new DefaultFormatter;
    }
1097158
public function getOptions(array $config)
    {
        $options = array_get($config, 'options', array());

        return array_diff_key($this->options, $options) + $options;
    }
440231
protected function getOptionsFromConfig(Config $config)
    {
        $options = [];

        foreach (static::$metaOptions as $option) {
            if (! $config->has($option)) {
                continue;
            }
            $options[static::$metaMap[$option]] = $config->get($option);
        }

        if ($visibility = $config->get('visibility')) {
            // For local reference
            // $options['visibility'] = $visibility;
            // For external reference
            $options['x-oss-object-acl'] = $visibility === AdapterInterface::VISIBILITY_PUBLIC ? OssClient::OSS_ACL_TYPE_PUBLIC_READ : OssClient::OSS_ACL_TYPE_PRIVATE;
        }

        if ($mimetype = $config->get('mimetype')) {
            // For local reference
            // $options['mimetype'] = $mimetype;
            // For external reference
            $options['Content-Type'] = $mimetype;
        }

        return $options;
    }
559890
public function transform(string $config = ''): array
    {
        $parsed = [];
        if (!empty($config)) {
            $config = \parse_ini_string($config, true, INI_SCANNER_RAW);
            if (\is_array($config)) {
                $parsed = $this->processNode($config);
            }
        }
        return $parsed;
    }
1042466
protected function getDsn(array $config)
    {
        if (! empty($config['tns'])) {
            return $config['tns'];
        }

        // parse configuration
        $config = $this->parseConfig($config);

        // check multiple connections/host, comma delimiter
        $config = $this->checkMultipleHostDsn($config);

        // return generated tns
        return $config['tns'];
    }