<?php

declare(strict_types=1);

namespace App\Domain\QrCode\ValueObject;

readonly class Position
{
    public function __construct(
        private int $row,
        private int $column
    ) {
    }

    public function getRow(): int
    {
        return $this->row;
    }

    public function getColumn(): int
    {
        return $this->column;
    }

    public function offset(int $rowOffset, int $columnOffset): self
    {
        return new self(
            $this->row + $rowOffset,
            $this->column + $columnOffset
        );
    }

    public function isWithinBounds(int $size): bool
    {
        return $this->row >= 0 && $this->row < $size &&
               $this->column >= 0 && $this->column < $size;
    }
}
