<?php

namespace App\Dto\Input;

use ApiPlatform\Metadata\ApiProperty;
use App\Dto\Output\ImageOutput;
use App\Dto\Output\ImageRepositoryOutput;
use App\Entity\ImageImageRepository;
use App\Entity\PxeTemplate;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;

final class ImageImageRepositoryInput
{
    #[Groups(['image-image-repository:write'])]
    public ?string $description = '';

    public function __construct(?ImageImageRepository $imageImageRepository = null)
    {
        if (!$imageImageRepository) {
            return;
        }

        $this->description = $imageImageRepository->getDescription();
    }

    public function createOrUpdateEntity(?ImageImageRepository $imageImageRepository = null): ImageImageRepository
    {
        if (!$imageImageRepository) {
            $imageImageRepository = new ImageImageRepository();
        }

        $imageImageRepository->setDescription($this->description);

        return $imageImageRepository;
    }
}
