<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Marketing\Model\Translation;

use CpCreation\VitiCore\Behavior\Impl\Translation;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\TranslationInterface;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
use Symfony\Component\Validator\Constraints as Assert;

#[ORM\Entity]
#[ORM\Table(name: 'marketing_review_request_config_translation')]
class ReviewRequestConfigurationTranslation implements TranslationInterface
{
    use Translation;

    public const int TITLE_MAX_LENGTH = 150;

    #[ORM\Id]
    #[ORM\Column(type: 'uuid')]
    #[ORM\GeneratedValue(strategy: 'NONE')]
    private UuidInterface $id;

    #[Assert\Length(max: self::TITLE_MAX_LENGTH)]
    #[ORM\Column(type: 'string', length: self::TITLE_MAX_LENGTH, nullable: true)]
    private ?string $emailTitle = null;

    #[Assert\Length(max: 50000)]
    #[ORM\Column(type: 'text', nullable: true)]
    private ?string $policyAdditionalContent = null;

    public function __construct()
    {
        $this->id = Uuid::uuid4();
    }

    public function getId(): UuidInterface
    {
        return $this->id;
    }

    public function getPolicyAdditionalContent(): ?string
    {
        return $this->policyAdditionalContent;
    }

    public function getEmailTitle(): ?string
    {
        return $this->emailTitle;
    }

    public function setEmailTitle(?string $emailTitle): void
    {
        if (null === $emailTitle) {
            $this->emailTitle = null;

            return;
        }

        $emailTitle = preg_replace('/\s+/u', ' ', mb_trim($emailTitle)) ?? '';
        $this->emailTitle = '' !== $emailTitle ? $emailTitle : null;
    }

    public function setPolicyAdditionalContent(?string $policyAdditionalContent): void
    {
        $this->policyAdditionalContent = null !== $policyAdditionalContent
            && '' !== mb_trim(strip_tags($policyAdditionalContent))
                ? mb_trim($policyAdditionalContent)
                : null;
    }
}
