Build a definition from the passed values.

@param Configuration $configuration The configuration.
@param array         $data          The configuration values.

@return Definition

@throws \InvalidArgumentException When a required key is missing.
182710
public function build(Configuration $configuration, array $data): Definition
    {
        foreach (['name', 'source', 'target'] as $key) {
            if (!array_key_exists($key, $data)) {
                throw new \InvalidArgumentException('Missing key "' . $key . '"');
            }
        }
        $overrides = $this->getDictionaryOverrides($data);
        $name      = $data['name'];
        $source    = $this->makeDictionary($configuration, $data['source'], $overrides, $name . '.source');
        $target    = $this->makeDictionary($configuration, $data['target'], $overrides, $name . '.target');
        unset($data['name'], $data['source'], $data['target']);

        return new CopyJobDefinition($name, $source, $target, $data);
    }
1192498
public function decrypt($data, Key $key)
	{
		// Validate key.
		if ($key->type != $this->keyType)
		{
			throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '.  Expected ' . $this->keyType . '.');
		}

		// Decrypt the data.
		$decrypted = trim(mcrypt_decrypt($this->type, $key->private, $data, $this->mode, $key->public));

		return $decrypted;
	}
1192685
protected function prepareServiceManager(Configuration $configuration)
    {
        $container      = $this->config->get('services', []);
        $serviceManager = new LeagueAdapter();

        foreach ($container as $className) {

            /** @var ServiceProvider $provider */
            $provider = new $className();

            if ( $provider instanceof ServiceProvider ) {
                throw new \InvalidArgumentException(
                    sprintf('Provider %s must be ServiceProvider', $className)
                );
            }

            $aliases = $provider->alias();
            if ( !is_array($aliases) ) {
                $aliases = [$aliases];
            }

            foreach ($aliases as $alias) {
                if ( $provider->share() ) {
                    $serviceManager->share($alias);
                }

                if ( $provider instanceof ServiceManager\SetterInjectorProvider ) {
                    $serviceManager
                        ->inflector($provider->inflector())
                        ->invokeMethod($provider->method(), [$alias]);
                }

                $provides = $provider->provide();

                if ( !is_callable($provides) ) {
                    $serviceManager->alias($alias, $provides);
                    continue;
                }

                $serviceManager->add(
                    $alias,
                    function () use ($provides, $serviceManager) {
                        return $serviceManager->call($provides);
                    }
                );
            }

        }

        // Add the ServiceManager and the Configuration
        $serviceManager->add(LeagueAdapter::class, $serviceManager);
        $serviceManager->add(ConfigurationContainer::class, $this->config);

        return $serviceManager;
    }
700454
public static function insert($key, $data)
    {
        if (self::$configurator instanceof ConfiguratorClass) {
            return self::$configurator->insert($key, $data);
        } else {
            return null;
        }
    }
747957
protected function mapConfiguration(array $configuration)
    {
        array_walk($configuration, function ($value, $key) use (&$configuration) {
            $newKey = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $key))));
            $configuration[$newKey] = $value;
        });

        return $configuration;
    }
364774
public function saveConfigurationForm(array $configuration, ParameterBag $data, ErrorList $error)
    {
        if ($this->hasConfigurationForm()) {
            throw new UserMessageException(t('The geolocator controller must implement the %s method', __FUNCTION__));
        }

        return $configuration;
    }
974267
public function fill($data)
    {
        if (!$this->object) {
            throw new InvalidArgumentException(
                'There are no object to be mapped'
            );
        }

        if (!is_object($data)) {
            throw new InvalidArgumentException('Data should be an object');
        }

        $data = $this->extractData($data);
        $allowed = $this->extractAllowedAttributes($this->class);

        foreach ($this->class->getProperties() as $property) {
            $name = $property->getName();
            if (!in_array($name, $allowed, true)
                || !array_key_exists(
                    $name,
                    $data
                )
            ) {
                continue;
            }

            $property->setAccessible(true);
            $property->setValue($this->object, $data[$name]);
        }

        return $this->object;
    }
340276
private function createApplicationConfiguration(array $configuration): ApplicationConfiguration
    {
        $resolver = new OptionsResolver();
        $applicationConfiguration = new ApplicationConfiguration();
        $applicationConfiguration->configureOptions($resolver);

        try {
            $applicationConfiguration->setParameters($resolver->resolve($configuration));
        } catch (Exception $exception) {
            throw new Exception(
                'An error has been found when processing the configuration of the admin application',
                0,
                $exception
            );
        }

        return $applicationConfiguration;
    }
89482
public function create($data)
    {
        if (! $data instanceof ExampleTag) {
            throw new \InvalidArgumentException(
                'The ExampleAssembler expected an ExampleTag object to base the descriptor on'
            );
        }

        $descriptor = new ExampleDescriptor($data->getName());
        $descriptor->setFilePath((string) $data->getFilePath());
        $descriptor->setStartingLine($data->getStartingLine());
        $descriptor->setLineCount($data->getLineCount());
        $descriptor->setDescription($data->getDescription());
        $descriptor->setExample($this->finder->find($descriptor));

        return $descriptor;
    }
694575
public function buildDescriptor($data)
    {
        $assembler = $this->getAssembler($data);
        if (!$assembler) {
            throw new \InvalidArgumentException(
                'Unable to build a Descriptor; the provided data did not match any Assembler ' .
                get_class($data)
            );
        }

        if ($assembler instanceof Builder\AssemblerAbstract) {
            $assembler->setBuilder($this);
        }

        // create Descriptor and populate with the provided data
        $descriptor = $assembler->create($data);
        if (!$descriptor) {
            return null;
        }

        return (!is_array($descriptor) && (!$descriptor instanceof Collection))
            ? $this->filterDescriptor($descriptor)
            : $this->filterEachDescriptor($descriptor);
    }
929862
public function sitesEdit(array $data)
    {
        if (!array_key_exists('code', $data)) {
            throw new \InvalidArgumentException(
                'Data must contain "code" parameter.'
            );
        }

        /* @noinspection PhpUndefinedMethodInspection */
        return $this->client->makeRequest(
            sprintf('/reference/sites/%s/edit', $data['code']),
            "POST",
            ['site' => json_encode($data)]
        );
    }
1153655
private function compile(Configuration $configuration)
    {
        $container = $this->loader->loadContainer($configuration);

        foreach ($configuration->getCompilerPasses() as $compilerPass) {
            $container->addCompilerPass($compilerPass);
        }

        $container->compile();

        return $container;
    }
54057
static public function getInstance( $configuration = array() )
    {
        if (empty( self::$instance )) {
            self::$instance = new Config( $configuration );
        }
        return self::$instance;
    }
457313
protected static function enrichForDecryptionProvider(
        Configuration $configuration,
        array &$baseConfiguration
    ) : void {
        if ($configuration->hasValue('sharedKey')) {
            $baseConfiguration['sharedKey'] = $configuration->getString('sharedKey', null);
        }

        if ($configuration->hasValue('new_privatekey')) {
            $baseConfiguration['privateKeys'][] = new PrivateKey(
                $configuration->getString('new_privatekey'),
                PrivateKey::NAME_NEW,
                $configuration->getString('new_privatekey_pass', null)
            );
        }

        if ($configuration->getBoolean('assertion.encryption', false)) {
            $baseConfiguration['privateKeys'][] = new PrivateKey(
                $configuration->getString('privatekey'),
                PrivateKey::NAME_DEFAULT,
                $configuration->getString('privatekey_pass', null)
            );

            if ($configuration->hasValue('encryption.blacklisted-algorithms')) {
                $baseConfiguration['blacklistedEncryptionAlgorithms'] = $configuration
                    ->getValue('encryption.blacklisted-algorithms');
            }
        }
    }
105612
protected function fileFactory(array $configuration): File
	{
		return (new File($this->container->get(FileSystem::class), $configuration['path'], $this->classWhitelist))->setPrefix($configuration['prefix'] ?? '');
	}
24293
private function createAdapterDefinition(array $adapter, $configuration)
    {
        $definition = new DefinitionDecorator(self::createServiceName('abstract'));
        $definition->setArguments([$adapter['type']]);
        $definition->addMethodCall('setConfiguration', [new Reference($configuration)]);

        return $definition;
    }
85121
public static function init(array $config)
    {
        if (empty($config['storage']) || ($config['storage'] != self::FILE && $config['storage'] != self::POP3)) {
            throw new \InvalidArgumentException('need at least type in params');
        }

        $className = __NAMESPACE__.'\\'.$config['storage'];

        return new  $className($config);
    }