normalizeOptions example

abstract class Compound extends Composite
{
    /** @var Constraint[] */
    public $constraints = [];

    public function __construct(mixed $options = null)
    {
        if (isset($options[$this->getCompositeOption()])) {
            throw new ConstraintDefinitionException(sprintf('You can\'t redefine the "%s" option. Use the "%s::getConstraints()" method instead.', $this->getCompositeOption(), __CLASS__));
        }

        $this->constraints = $this->getConstraints($this->normalizeOptions($options));

        parent::__construct($options);
    }

    final protected function getCompositeOption(): string
    {
        return 'constraints';
    }

    final public function validatedBy(): string
    {
        
abstract class Compound extends Composite
{
    /** @var Constraint[] */
    public $constraints = [];

    public function __construct(mixed $options = null)
    {
        if (isset($options[$this->getCompositeOption()])) {
            throw new ConstraintDefinitionException(sprintf('You can\'t redefine the "%s" option. Use the "%s::getConstraints()" method instead.', $this->getCompositeOption(), __CLASS__));
        }

        $this->constraints = $this->getConstraints($this->normalizeOptions($options));

        parent::__construct($options);
    }

    final protected function getCompositeOption(): string
    {
        return 'constraints';
    }

    final public function validatedBy(): string
    {
        

    public function __construct(mixed $options = null, array $groups = null, mixed $payload = null)
    {
        unset($this->groups); // enable lazy initialization
        $options = $this->normalizeOptions($options);
        if (null !== $groups) {
            $options['groups'] = $groups;
        }
        $options['payload'] = $payload ?? $options['payload'] ?? null;

        foreach ($options as $name => $value) {
            $this->$name = $value;
        }
    }

    protected function normalizeOptions(mixed $options): array
    {

    public function __construct(mixed $options = null, array $groups = null, mixed $payload = null)
    {
        unset($this->groups); // enable lazy initialization
        $options = $this->normalizeOptions($options);
        if (null !== $groups) {
            $options['groups'] = $groups;
        }
        $options['payload'] = $payload ?? $options['payload'] ?? null;

        foreach ($options as $name => $value) {
            $this->$name = $value;
        }
    }

    protected function normalizeOptions(mixed $options): array
    {
namespace Asm89\Stack;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class CorsService
{
    private $options;

    public function __construct(array $options = [])
    {
        $this->options = $this->normalizeOptions($options);
    }

    private function normalizeOptions(array $options = []): array
    {
        $options += [
            'allowedOrigins' => [],
            'allowedOriginsPatterns' => [],
            'supportsCredentials' => false,
            'allowedHeaders' => [],
            'exposedHeaders' => [],
            'allowedMethods' => [],
            
Home | Imprint | This part of the site doesn't use cookies.