<?php

declare(strict_types=1);

namespace KupShop\GraphQLBundle\ApiShared\Types\Product;

use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Type;

#[Type]
class ProductAttachment
{
    public function __construct(protected readonly array $attachment)
    {
    }

    #[Field(description: 'Název souboru')]
    public function getName(): string
    {
        return $this->attachment['title'];
    }

    #[Field(description: 'URL')]
    public function getUrl(): ?string
    {
        return $this->attachment['link'];
    }

    #[Field(description: 'Pozice přílohy')]
    public function getPosition(): int
    {
        return (int) $this->attachment['position'];
    }
}
