Validates the search clients config.

@param   array   $clients
@return  self
@throws  InvalidConfigurationException
485144
private function validateSearchClients(array $clients)
    {
        foreach ($clients as $name => $config) {
            $this->validateTypeAndService($config, sprintf('as3_modlr.search_clients.%s', $name));
            switch ($config['type']) {
                case 'elastic':
                    $this->validateLibClassExists('Search\Elastic\Client', sprintf('as3_modlr.search_clients.%s.type', $name));
                    break;
                default:
                    break;
            }
        }
    }
665273
public function injectSettings(array $settings) {
		if (isset($settings['server'])) {
			if (!is_array($settings['server'])) {
				throw new Exception('Invalid Flowpack.SingleSignOn.Client.server configuration', 1351688261);
			}
			$this->serverConfigurations = $settings['server'];
		}
	}
677913
private function isValidConfigs(array $configs): void
    {
        $allowedConfigKeys = $this->getAllowedConfigKeys();
        if (!empty($configs)) {
            foreach ($configs as $key => $value) {
                if (!\in_array($key, $allowedConfigKeys, true)) {
                    throw new InvalidKeyException(sprintf(
                        '%s is not a valid key. configs must only contain "%s".',
                        $key,
                        implode(', ', $allowedConfigKeys)
                    ));
                }

                $this->isBool($key, $value);
                $this->isString($key, $value);
                $this->isValidNBest($key, $value);
            }
        }
    }
55673
public function getClient($name = null)
    {
        if (null === $name) {
            $name = $this->defaultClientName;
        }

        if (in_array($name, $this->getClientNames())) {
            return $this->clients[$name];
        }

        throw new \InvalidArgumentException(($name === null ? 'default client' : 'client ' . $name) . ' not configured');
    }
1198759
protected function convertClientToId($client)
    {
        if (!isset($this->clientsMap[$client])) {
            throw new InvalidValueException('Client "' . $client . '" was not found');
        }

        return $this->clientsMap[$client];
    }
299792
public static function hydrateCollection(array $clients)
    {
        $hydrated = [];

        foreach ($clients as $client) {
            $hydrated[] = self::hydrate($client);
        }

        return $hydrated;
    }
902029
public function configure(array $config)
    {
        if (isset($config['services'])) {
            foreach ($config['services'] as $service) {
                $this->validate($service);
            }
        }

        parent::configure($config);

        return $this;
    }
890022
public function setInputsToFilter($inputs)
    {
        // No need to apply validation groups for empty arrays
        if (!is_array($inputs) || $this->needsFiltering($inputs)) {
            try {
                if ($inputs === null) {
                    // Provide Zend's expected value when intending to filter all inputs...
                    $group = self::VALIDATE_ALL;
                } elseif (is_array($inputs)) {
                    $knownInputs = array_keys($this->getInputs());
                    $group = array_intersect($inputs, $knownInputs);
                } else {
                    $group = $inputs;
                }

                parent::setValidationGroup($group);
            } catch (InputFilterException $e) {
                throw new Exception\InvalidArgumentException(
                    sprintf('Failed to set inputs to filter: %s', $e->getMessage()),
                    0,
                    $e
                );
            }
        }

        // Apply only after we made sure the provided inputs are valid
        $this->inputsToFilter = $inputs;

        return $this;
    }
949589
public function setNameservers(array $nameservers = [])
    {
        foreach ($nameservers as $nameserver) {
            if (!($nameserver instanceof HostInterface)) {
                throw new UnexpectedValueException(sprintf(
                    'Invalid class of the nameservers item. Items of the nameservers must be instance of %s or %s.',
                    HostObjectHelper::class,
                    HostAttributeHelper::class
                ));
            }
        }

        $this->nameservers = $nameservers;

        return $this;
    }
407082
protected function validateServerConfig($config)
    {
        if (!is_array($config)) {
            throw new InvalidArgumentException($this->translate(
                'Server configuration should be an array or Traversable.'
            ));
        }
        if (!isset($config['id']) || empty($config['id'])) {
            throw new InvalidArgumentException($this->translate(
                'Cannot find server id in configuration.'
            ));
        }
        if (!isset($config['connection']) || empty($config['connection'])) {
            throw new InvalidArgumentException($this->translate(
                'Cannot find connection type in configuration.'
            ));
        }
    }
1039277
public function execute(array $clients) {
        if ($clients) {
            $mh      = curl_multi_init();
            $handles = [];
            /**@var \wulaphp\restful\RESTFulClient $client */
            foreach ($clients as $i => $client) {
                $ch             = $client->curl;
                $handles [ $i ] = ['h' => $ch, 'c' => $client];
                curl_multi_add_handle($mh, $ch);
            }
            $active = null;
            do {
                curl_multi_exec($mh, $active);
                if ($active > 0) {
                    usleep(50);
                }
            } while ($active > 0);
            $rsts = [];
            foreach ($handles as $i => $h) {
                /**@var \wulaphp\restful\RESTFulClient $client */
                $client      = $h ['c'];
                $rsts [ $i ] = $client->getReturn(curl_multi_getcontent($client->curl));
                curl_multi_remove_handle($mh, $h ['h']);
            }
            curl_multi_close($mh);

            return $rsts;
        }

        return [];
    }
377185
protected function processConfiguration(array $configs) {
        $config = [];

        foreach ($configs as $group) {
            $config = array_extend_distinct($config, $group);
        }

        return $config;
    }
673949
public function setup(array $formatters)
    {
        foreach ($formatters as $formatterName => $formatter) {
            if (!$formatter instanceof TrackingParameterFormatterInterface) {
                throw new InvalidConfigurationException(
                    sprintf('Invalid tracking parameter formatter "%s".', $formatterName)
                );
            }
        }

        $this->formatters = $formatters;
    }
216478
private function validateKeys(array $keys)
    {
        foreach ($keys as $key) {
            $key = (string)$key;
            $this->validateKey($key);
        }
    }
1324913
protected function createClientCredentials(array $clientCredentials)
    {
        $keys = array('identifier', 'secret');

        foreach ($keys as $key) {
            if (!isset($clientCredentials[$key])) {
                throw new \InvalidArgumentException("Missing client credentials key [$key] from options.");
            }
        }

        if (isset($clientCredentials['rsa_private_key']) && isset($clientCredentials['rsa_public_key'])) {
            $_clientCredentials = new RsaClientCredentials();
            $_clientCredentials->setRsaPrivateKey($clientCredentials['rsa_private_key']);
            $_clientCredentials->setRsaPublicKey($clientCredentials['rsa_public_key']);
        } else {
            $_clientCredentials = new ClientCredentials();
        }

        $_clientCredentials->setIdentifier($clientCredentials['identifier']);
        $_clientCredentials->setSecret($clientCredentials['secret']);

        if (isset($clientCredentials['callback_uri'])) {
            $_clientCredentials->setCallbackUri($clientCredentials['callback_uri']);
        }

        return $_clientCredentials;
    }
781785
public function authenticate(array $config)
    {
        if (!$this->client) {
            throw new InvalidArgumentException('The client instance was not given to the application authenticator.');
        }

        if (!array_key_exists('clientId', $config) || !array_key_exists('clientSecret', $config)) {
            throw new InvalidArgumentException('The application authenticator requires a client id and secret.');
        }

        $this->client->authenticate($config['clientId'], $config['clientSecret'], Client::AUTH_URL_CLIENT_ID);

        return $this->client;
    }
464831
public function client(array $config)
    {
        $key = $this->getClientKey($config);

        if (isset($this->clients[$key])) {
            return $this->clients[$key];
        }

        return $this->clients[$key] = $this->createClient($config);
    }