<?php

namespace Symfony\Config;

require_once __DIR__.\DIRECTORY_SEPARATOR.'PimUser'.\DIRECTORY_SEPARATOR.'ResetConfig.php';
require_once __DIR__.\DIRECTORY_SEPARATOR.'PimUser'.\DIRECTORY_SEPARATOR.'EmailConfig.php';
require_once __DIR__.\DIRECTORY_SEPARATOR.'PimUser'.\DIRECTORY_SEPARATOR.'PrivilegesConfig.php';
require_once __DIR__.\DIRECTORY_SEPARATOR.'PimUser'.\DIRECTORY_SEPARATOR.'LoginFormConfig.php';

use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;

/**
 * This class is automatically generated to help in creating a config.
 */
class PimUserConfig implements \Symfony\Component\Config\Builder\ConfigBuilderInterface
{
    private $reset;
    private $email;
    private $privileges;
    private $loginForm;
    private $_usedProperties = [];

    public function reset(array $value = []): \Symfony\Config\PimUser\ResetConfig
    {
        if (null === $this->reset) {
            $this->_usedProperties['reset'] = true;
            $this->reset = new \Symfony\Config\PimUser\ResetConfig($value);
        } elseif (0 < \func_num_args()) {
            throw new InvalidConfigurationException('The node created by "reset()" has already been initialized. You cannot pass values the second time you call reset().');
        }

        return $this->reset;
    }

    public function email(array $value = []): \Symfony\Config\PimUser\EmailConfig
    {
        if (null === $this->email) {
            $this->_usedProperties['email'] = true;
            $this->email = new \Symfony\Config\PimUser\EmailConfig($value);
        } elseif (0 < \func_num_args()) {
            throw new InvalidConfigurationException('The node created by "email()" has already been initialized. You cannot pass values the second time you call email().');
        }

        return $this->email;
    }

    public function privileges(string $name, array $value = []): \Symfony\Config\PimUser\PrivilegesConfig
    {
        if (!isset($this->privileges[$name])) {
            $this->_usedProperties['privileges'] = true;
            $this->privileges[$name] = new \Symfony\Config\PimUser\PrivilegesConfig($value);
        } elseif (1 < \func_num_args()) {
            throw new InvalidConfigurationException('The node created by "privileges()" has already been initialized. You cannot pass values the second time you call privileges().');
        }

        return $this->privileges[$name];
    }

    public function loginForm(array $value = []): \Symfony\Config\PimUser\LoginFormConfig
    {
        if (null === $this->loginForm) {
            $this->_usedProperties['loginForm'] = true;
            $this->loginForm = new \Symfony\Config\PimUser\LoginFormConfig($value);
        } elseif (0 < \func_num_args()) {
            throw new InvalidConfigurationException('The node created by "loginForm()" has already been initialized. You cannot pass values the second time you call loginForm().');
        }

        return $this->loginForm;
    }

    public function getExtensionAlias(): string
    {
        return 'pim_user';
    }

    public function __construct(array $value = [])
    {
        if (array_key_exists('reset', $value)) {
            $this->_usedProperties['reset'] = true;
            $this->reset = new \Symfony\Config\PimUser\ResetConfig($value['reset']);
            unset($value['reset']);
        }

        if (array_key_exists('email', $value)) {
            $this->_usedProperties['email'] = true;
            $this->email = new \Symfony\Config\PimUser\EmailConfig($value['email']);
            unset($value['email']);
        }

        if (array_key_exists('privileges', $value)) {
            $this->_usedProperties['privileges'] = true;
            $this->privileges = array_map(function ($v) { return new \Symfony\Config\PimUser\PrivilegesConfig($v); }, $value['privileges']);
            unset($value['privileges']);
        }

        if (array_key_exists('login_form', $value)) {
            $this->_usedProperties['loginForm'] = true;
            $this->loginForm = new \Symfony\Config\PimUser\LoginFormConfig($value['login_form']);
            unset($value['login_form']);
        }

        if ([] !== $value) {
            throw new InvalidConfigurationException(sprintf('The following keys are not supported by "%s": ', __CLASS__).implode(', ', array_keys($value)));
        }
    }

    public function toArray(): array
    {
        $output = [];
        if (isset($this->_usedProperties['reset'])) {
            $output['reset'] = $this->reset->toArray();
        }
        if (isset($this->_usedProperties['email'])) {
            $output['email'] = $this->email->toArray();
        }
        if (isset($this->_usedProperties['privileges'])) {
            $output['privileges'] = array_map(function ($v) { return $v->toArray(); }, $this->privileges);
        }
        if (isset($this->_usedProperties['loginForm'])) {
            $output['login_form'] = $this->loginForm->toArray();
        }

        return $output;
    }

}
