<?php

namespace Symfony\Config\Twig;

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 DateConfig 
{
    private $format;
    private $intervalFormat;
    private $timezone;
    private $_usedProperties = [];

    /**
     * @default 'F j, Y H:i'
     * @param ParamConfigurator|mixed $value
     * @return $this
     */
    public function format($value): static
    {
        $this->_usedProperties['format'] = true;
        $this->format = $value;

        return $this;
    }

    /**
     * @default '%d days'
     * @param ParamConfigurator|mixed $value
     * @return $this
     */
    public function intervalFormat($value): static
    {
        $this->_usedProperties['intervalFormat'] = true;
        $this->intervalFormat = $value;

        return $this;
    }

    /**
     * The timezone used when formatting dates, when set to null, the timezone returned by date_default_timezone_get() is used.
     * @default null
     * @param ParamConfigurator|mixed $value
     * @return $this
     */
    public function timezone($value): static
    {
        $this->_usedProperties['timezone'] = true;
        $this->timezone = $value;

        return $this;
    }

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

        if (array_key_exists('interval_format', $config)) {
            $this->_usedProperties['intervalFormat'] = true;
            $this->intervalFormat = $config['interval_format'];
            unset($config['interval_format']);
        }

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

        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['format'])) {
            $output['format'] = $this->format;
        }
        if (isset($this->_usedProperties['intervalFormat'])) {
            $output['interval_format'] = $this->intervalFormat;
        }
        if (isset($this->_usedProperties['timezone'])) {
            $output['timezone'] = $this->timezone;
        }

        return $output;
    }

}
