<?php

namespace Symfony\Config\NetzmachtContaoFormDesigner;

require_once __DIR__.\DIRECTORY_SEPARATOR.'WidgetsConfig'.\DIRECTORY_SEPARATOR.'AttributesConfig.php';

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

/**
 * This class is automatically generated to help in creating a config.
 */
class WidgetsConfig 
{
    private $help;
    private $templates;
    private $attributes;
    private $palettes;
    private $_usedProperties = [];

    /**
     * Widget supports help message
     * @default false
     * @param ParamConfigurator|bool $value
     * @return $this
     */
    public function help($value): self
    {
        $this->_usedProperties['help'] = true;
        $this->help = $value;

        return $this;
    }

    /**
     * @param ParamConfigurator|list<mixed|ParamConfigurator> $value
     * @return $this
     */
    public function templates($value): self
    {
        $this->_usedProperties['templates'] = true;
        $this->templates = $value;

        return $this;
    }

    public function attributes(array $value = []): \Symfony\Config\NetzmachtContaoFormDesigner\WidgetsConfig\AttributesConfig
    {
        $this->_usedProperties['attributes'] = true;

        return $this->attributes[] = new \Symfony\Config\NetzmachtContaoFormDesigner\WidgetsConfig\AttributesConfig($value);
    }

    /**
     * @param ParamConfigurator|list<mixed|ParamConfigurator> $value
     * @return $this
     */
    public function palettes($value): self
    {
        $this->_usedProperties['palettes'] = true;
        $this->palettes = $value;

        return $this;
    }

    public function __construct(array $value = [])
    {
        if (array_key_exists('help', $value)) {
            $this->_usedProperties['help'] = true;
            $this->help = $value['help'];
            unset($value['help']);
        }

        if (array_key_exists('templates', $value)) {
            $this->_usedProperties['templates'] = true;
            $this->templates = $value['templates'];
            unset($value['templates']);
        }

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

        if (array_key_exists('palettes', $value)) {
            $this->_usedProperties['palettes'] = true;
            $this->palettes = $value['palettes'];
            unset($value['palettes']);
        }

        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['help'])) {
            $output['help'] = $this->help;
        }
        if (isset($this->_usedProperties['templates'])) {
            $output['templates'] = $this->templates;
        }
        if (isset($this->_usedProperties['attributes'])) {
            $output['attributes'] = array_map(function ($v) { return $v->toArray(); }, $this->attributes);
        }
        if (isset($this->_usedProperties['palettes'])) {
            $output['palettes'] = $this->palettes;
        }

        return $output;
    }

}
