protected function configureRepository(Config $config): OptionRepository
    {
        $repositories = [];

        foreach ($config->getAll() as $class => $optionsArray) {
            $prefix = array_key_exists(OptionRepository::PREFIX, $optionsArray)
                ? $optionsArray[OptionRepository::PREFIX]
                : '';
            $options = $this->configureOptions((array)$optionsArray);

            try {
                $repositories[] = $this->isPrefixable($class)
                    ? new $class($prefix, $options->getValues())
                    : new $class($options->getValues());
            } catch (Exception $exception) {
                throw InvalidOptionRepository::fromInstantiationException($class, $exception);
            }
        }

        if (empty($repositories)) {
            throw InvalidOptionRepository::fromConfig($config);
        }

        if (1 === count($repositories)) {
            return $repositories[0];
        }

        return new AggregateOptionRepository($repositories);
    }
protected function configureRepository(Config $config): OptionRepository
    {
        $repositories = [];

        foreach ($config->getAll() as $class => $optionsArray) {
            $prefix = array_key_exists(OptionRepository::PREFIX, $optionsArray)
                ? $optionsArray[OptionRepository::PREFIX]
                : '';
            $options = $this->configureOptions((array)$optionsArray);

            try {
                $repositories[] = $this->isPrefixable($class)
                    ? new $class($prefix, $options->getValues())
                    : new $class($options->getValues());
            } catch (Exception $exception) {
                throw InvalidOptionRepository::fromInstantiationException($class, $exception);
            }
        }

        if (empty($repositories)) {
            throw InvalidOptionRepository::fromConfig($config);
        }

        if (1 === count($repositories)) {
            return $repositories[0];
        }

        return new AggregateOptionRepository($repositories);
    }
protected function configureRepository ( Config $ config ) : OptionRepository { $ repositories = [ ] ; foreach ( $ config -> getAll ( ) as $ class => $ optionsArray ) { $ prefix = array_key_exists ( OptionRepository :: PREFIX , $ optionsArray ) ? $ optionsArray [ OptionRepository :: PREFIX ] : '' ; $ options = $ this -> configureOptions ( ( array ) $ optionsArray ) ; try { $ repositories [ ] = $ this -> isPrefixable ( $ class ) ? new $ class ( $ prefix , $ options -> getValues ( ) ) : new $ class ( $ options -> getValues ( ) ) ; } catch ( Exception $ exception ) { throw InvalidOptionRepository :: fromInstantiationException ( $ class , $ exception ) ; } } if ( empty ( $ repositories ) ) { throw InvalidOptionRepository :: fromConfig ( $ config ) ; } if ( 1 === count ( $ repositories ) ) { return $ repositories [ 0 ] ; } return new AggregateOptionRepository ( $ repositories ) ; }
Configure a single repository from a Config file.

This will automatically regroup an array of repositories into an AggregateOptionRepository.

@since 0.1.4

@param Config $config Config instance to use.

@return OptionRepository Option repository that was built from the passed-in repository.
@throws InvalidOptionRepository If the repository could not be configured.
@throws InvalidOptionRepository If the repository could not be instantiated.
Configure a single repository from a Config file .