<?php

namespace Symfony\Config;

require_once __DIR__.\DIRECTORY_SEPARATOR.'MisdPhoneNumber'.\DIRECTORY_SEPARATOR.'TwigConfig.php';
require_once __DIR__.\DIRECTORY_SEPARATOR.'MisdPhoneNumber'.\DIRECTORY_SEPARATOR.'FormConfig.php';
require_once __DIR__.\DIRECTORY_SEPARATOR.'MisdPhoneNumber'.\DIRECTORY_SEPARATOR.'SerializerConfig.php';
require_once __DIR__.\DIRECTORY_SEPARATOR.'MisdPhoneNumber'.\DIRECTORY_SEPARATOR.'ValidatorConfig.php';

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

/**
 * This class is automatically generated to help in creating a config.
 */
class MisdPhoneNumberConfig implements \Symfony\Component\Config\Builder\ConfigBuilderInterface
{
    private $twig;
    private $form;
    private $serializer;
    private $validator;
    private $_usedProperties = [];
    private $_hasDeprecatedCalls = false;

    /**
     * @template TValue of mixed
     * @param TValue $value
     * @default {"enabled":true,"default_region":"ZZ","format":0}
     * @return \Symfony\Config\MisdPhoneNumber\TwigConfig|$this
     * @psalm-return (TValue is array ? \Symfony\Config\MisdPhoneNumber\TwigConfig : static)
     * @deprecated since Symfony 7.4
     */
    public function twig(mixed $value = []): \Symfony\Config\MisdPhoneNumber\TwigConfig|static
    {
        $this->_hasDeprecatedCalls = true;
        if (!\is_array($value)) {
            $this->_usedProperties['twig'] = true;
            $this->twig = $value;

            return $this;
        }

        if (!$this->twig instanceof \Symfony\Config\MisdPhoneNumber\TwigConfig) {
            $this->_usedProperties['twig'] = true;
            $this->twig = new \Symfony\Config\MisdPhoneNumber\TwigConfig($value);
        } elseif (0 < \func_num_args()) {
            throw new InvalidConfigurationException('The node created by "twig()" has already been initialized. You cannot pass values the second time you call twig().');
        }

        return $this->twig;
    }

    /**
     * @template TValue of mixed
     * @param TValue $value
     * @default {"enabled":true}
     * @return \Symfony\Config\MisdPhoneNumber\FormConfig|$this
     * @psalm-return (TValue is array ? \Symfony\Config\MisdPhoneNumber\FormConfig : static)
     * @deprecated since Symfony 7.4
     */
    public function form(mixed $value = []): \Symfony\Config\MisdPhoneNumber\FormConfig|static
    {
        $this->_hasDeprecatedCalls = true;
        if (!\is_array($value)) {
            $this->_usedProperties['form'] = true;
            $this->form = $value;

            return $this;
        }

        if (!$this->form instanceof \Symfony\Config\MisdPhoneNumber\FormConfig) {
            $this->_usedProperties['form'] = true;
            $this->form = new \Symfony\Config\MisdPhoneNumber\FormConfig($value);
        } elseif (0 < \func_num_args()) {
            throw new InvalidConfigurationException('The node created by "form()" has already been initialized. You cannot pass values the second time you call form().');
        }

        return $this->form;
    }

    /**
     * @template TValue of mixed
     * @param TValue $value
     * @default {"enabled":true,"default_region":"ZZ","format":0}
     * @return \Symfony\Config\MisdPhoneNumber\SerializerConfig|$this
     * @psalm-return (TValue is array ? \Symfony\Config\MisdPhoneNumber\SerializerConfig : static)
     * @deprecated since Symfony 7.4
     */
    public function serializer(mixed $value = []): \Symfony\Config\MisdPhoneNumber\SerializerConfig|static
    {
        $this->_hasDeprecatedCalls = true;
        if (!\is_array($value)) {
            $this->_usedProperties['serializer'] = true;
            $this->serializer = $value;

            return $this;
        }

        if (!$this->serializer instanceof \Symfony\Config\MisdPhoneNumber\SerializerConfig) {
            $this->_usedProperties['serializer'] = true;
            $this->serializer = new \Symfony\Config\MisdPhoneNumber\SerializerConfig($value);
        } elseif (0 < \func_num_args()) {
            throw new InvalidConfigurationException('The node created by "serializer()" has already been initialized. You cannot pass values the second time you call serializer().');
        }

        return $this->serializer;
    }

    /**
     * @template TValue of mixed
     * @param TValue $value
     * @default {"enabled":true,"default_region":"ZZ","format":1}
     * @return \Symfony\Config\MisdPhoneNumber\ValidatorConfig|$this
     * @psalm-return (TValue is array ? \Symfony\Config\MisdPhoneNumber\ValidatorConfig : static)
     * @deprecated since Symfony 7.4
     */
    public function validator(mixed $value = []): \Symfony\Config\MisdPhoneNumber\ValidatorConfig|static
    {
        $this->_hasDeprecatedCalls = true;
        if (!\is_array($value)) {
            $this->_usedProperties['validator'] = true;
            $this->validator = $value;

            return $this;
        }

        if (!$this->validator instanceof \Symfony\Config\MisdPhoneNumber\ValidatorConfig) {
            $this->_usedProperties['validator'] = true;
            $this->validator = new \Symfony\Config\MisdPhoneNumber\ValidatorConfig($value);
        } elseif (0 < \func_num_args()) {
            throw new InvalidConfigurationException('The node created by "validator()" has already been initialized. You cannot pass values the second time you call validator().');
        }

        return $this->validator;
    }

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

    public function __construct(array $config = [])
    {
        if (array_key_exists('twig', $config)) {
            $this->_usedProperties['twig'] = true;
            $this->twig = \is_array($config['twig']) ? new \Symfony\Config\MisdPhoneNumber\TwigConfig($config['twig']) : $config['twig'];
            unset($config['twig']);
        }

        if (array_key_exists('form', $config)) {
            $this->_usedProperties['form'] = true;
            $this->form = \is_array($config['form']) ? new \Symfony\Config\MisdPhoneNumber\FormConfig($config['form']) : $config['form'];
            unset($config['form']);
        }

        if (array_key_exists('serializer', $config)) {
            $this->_usedProperties['serializer'] = true;
            $this->serializer = \is_array($config['serializer']) ? new \Symfony\Config\MisdPhoneNumber\SerializerConfig($config['serializer']) : $config['serializer'];
            unset($config['serializer']);
        }

        if (array_key_exists('validator', $config)) {
            $this->_usedProperties['validator'] = true;
            $this->validator = \is_array($config['validator']) ? new \Symfony\Config\MisdPhoneNumber\ValidatorConfig($config['validator']) : $config['validator'];
            unset($config['validator']);
        }

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

    public function toArray(): array
    {
        $output = [];
        if (isset($this->_usedProperties['twig'])) {
            $output['twig'] = $this->twig instanceof \Symfony\Config\MisdPhoneNumber\TwigConfig ? $this->twig->toArray() : $this->twig;
        }
        if (isset($this->_usedProperties['form'])) {
            $output['form'] = $this->form instanceof \Symfony\Config\MisdPhoneNumber\FormConfig ? $this->form->toArray() : $this->form;
        }
        if (isset($this->_usedProperties['serializer'])) {
            $output['serializer'] = $this->serializer instanceof \Symfony\Config\MisdPhoneNumber\SerializerConfig ? $this->serializer->toArray() : $this->serializer;
        }
        if (isset($this->_usedProperties['validator'])) {
            $output['validator'] = $this->validator instanceof \Symfony\Config\MisdPhoneNumber\ValidatorConfig ? $this->validator->toArray() : $this->validator;
        }
        if ($this->_hasDeprecatedCalls) {
            trigger_deprecation('symfony/config', '7.4', 'Calling any fluent method on "%s" is deprecated; pass the configuration to the constructor instead.', $this::class);
        }

        return $output;
    }

}
