<?php

declare(strict_types=1);

/**
 * @author Colinet Julien
 */

namespace CpCreation\VitiCore\Popup\Model;

use CpCreation\VitiCore\Behavior\HasDisable;
use CpCreation\VitiCore\Behavior\HasImage;
use CpCreation\VitiCore\Behavior\HasTimestamp;
use CpCreation\VitiCore\Behavior\HasTranslatable;
use CpCreation\VitiCore\Behavior\HasVideo;
use CpCreation\VitiCore\Behavior\Impl\Disable;
use CpCreation\VitiCore\Behavior\Impl\Image;
use CpCreation\VitiCore\Behavior\Impl\Timestamp;
use CpCreation\VitiCore\Behavior\Impl\Translatable;
use CpCreation\VitiCore\Behavior\Impl\Video;
use CpCreation\VitiCore\Popup\Repository\PopupRepository;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
use Symfony\Component\Validator\Constraints as Assert;

#[ORM\Entity(repositoryClass: PopupRepository::class)]
#[ORM\Table(name: 'popup_popup')]
#[ORM\HasLifecycleCallbacks]
class Popup implements HasImage, HasTimestamp, HasTranslatable, HasVideo, HasDisable
{
    use Disable;
    use Image;
    use Timestamp;
    use Translatable;
    use Video;

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

    #[ORM\Column(type: 'datetime', nullable: true)]
    #[Assert\NotBlank]
    private ?\DateTime $unPublishedAt = null;

    #[ORM\Column(type: 'datetime', nullable: true)]
    #[Assert\NotBlank]
    private ?\DateTime $publishedAt = null;

    #[ORM\Column(type: 'boolean', options: ['default' => true])]
    private bool $popup = true;

    #[ORM\Column(type: 'boolean', options: ['default' => true])]
    private bool $showTitleInBanner = true;

    #[ORM\Column(type: 'text', nullable: true)]
    private ?string $url = null;

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

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

    public function getUnPublishedAt(): ?\DateTime
    {
        return $this->unPublishedAt;
    }

    public function setUnPublishedAt(?\DateTime $unPublishedAt): void
    {
        $this->unPublishedAt = $unPublishedAt;
    }

    public function getPublishedAt(): ?\DateTime
    {
        return $this->publishedAt;
    }

    public function setPublishedAt(?\DateTime $publishedAt): void
    {
        $this->publishedAt = $publishedAt;
    }

    public function isPopup(): bool
    {
        return $this->popup;
    }

    public function setPopup(bool $popup): void
    {
        $this->popup = $popup;
    }

    public function isShowTitleInBanner(): bool
    {
        return $this->showTitleInBanner;
    }

    public function setShowTitleInBanner(bool $showTitleInBanner): void
    {
        $this->showTitleInBanner = $showTitleInBanner;
    }

    public function getUrl(): ?string
    {
        return $this->url;
    }

    public function setUrl(?string $url): void
    {
        $this->url = $url;
    }
}
