<?php

declare(strict_types=1);

namespace App\Domain\QrCode\ValueObject;

readonly class QrCodeConfig
{
    /**
     * @param int $moduleSize Größe eines QR-Code-Moduls in Pixeln
     * @param int $margin Rand um den QR-Code in Modulen
     * @param string $foregroundColor Vordergrundfarbe (für SVG)
     * @param string $backgroundColor Hintergrundfarbe (für SVG)
     */
    public function __construct(
        private int $moduleSize = 4,
        private int $margin = 4,
        private string $foregroundColor = '#000000',
        private string $backgroundColor = '#FFFFFF'
    ) {
    }

    public function getModuleSize(): int
    {
        return $this->moduleSize;
    }

    public function getMargin(): int
    {
        return $this->margin;
    }

    public function getForegroundColor(): string
    {
        return $this->foregroundColor;
    }

    public function getBackgroundColor(): string
    {
        return $this->backgroundColor;
    }

    public function withModuleSize(int $moduleSize): self
    {
        return new self(
            $moduleSize,
            $this->margin,
            $this->foregroundColor,
            $this->backgroundColor
        );
    }

    public function withMargin(int $margin): self
    {
        return new self(
            $this->moduleSize,
            $margin,
            $this->foregroundColor,
            $this->backgroundColor
        );
    }

    public function withColors(string $foreground, string $background): self
    {
        return new self(
            $this->moduleSize,
            $this->margin,
            $foreground,
            $background
        );
    }
}
