<?php

declare(strict_types=1);

namespace App\Entity\Tenant;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'news')]
#[ORM\HasLifecycleCallbacks]
class News
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(type: 'integer')]
    private ?int $id = null;

    #[ORM\Column(type: 'string', length: 500)]
    private string $title;

    #[ORM\Column(type: 'string', length: 500, unique: true)]
    private string $slug;

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

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

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

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

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

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

    #[ORM\Column(type: 'json', nullable: true)]
    private ?array $gallery = null;

    #[ORM\ManyToOne(targetEntity: Category::class, inversedBy: 'news')]
    #[ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
    private ?Category $category = null;

    #[ORM\ManyToOne(targetEntity: Author::class)]
    #[ORM\JoinColumn(name: 'author_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
    private ?Author $author = null;

    /** @var Collection<int, Tag> */
    #[ORM\ManyToMany(targetEntity: Tag::class, inversedBy: 'news')]
    #[ORM\JoinTable(name: 'news_tags')]
    private Collection $tags;

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

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

    #[ORM\Column(type: 'string', length: 20, options: ['default' => 'draft'])]
    private string $status = 'draft';

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

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

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

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

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

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

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

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

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

    #[ORM\Column(type: 'integer', options: ['default' => 0])]
    private int $seoScore = 0;

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

    #[ORM\Column(type: 'string', length: 100, options: ['default' => 'index,follow'])]
    private string $robotsMeta = 'index,follow';

    #[ORM\Column(type: 'integer', options: ['default' => 0])]
    private int $viewCount = 0;

    #[ORM\Column(type: 'integer', options: ['default' => 0])]
    private int $commentCount = 0;

    #[ORM\Column(type: 'integer', options: ['default' => 0])]
    private int $shareCount = 0;

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

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

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

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

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

    #[ORM\Column(type: 'datetime_immutable', nullable: true)]
    private ?\DateTimeImmutable $publishedAt = null;

    #[ORM\Column(type: 'datetime_immutable', nullable: true)]
    private ?\DateTimeImmutable $scheduledAt = null;

    #[ORM\Column(type: 'datetime_immutable')]
    private \DateTimeImmutable $createdAt;

    #[ORM\Column(type: 'datetime_immutable')]
    private \DateTimeImmutable $updatedAt;

    public function __construct()
    {
        $this->tags = new ArrayCollection();
    }

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

    public function getTitle(): string
    {
        return $this->title;
    }

    public function setTitle(string $title): self
    {
        $this->title = $title;

        return $this;
    }

    public function getSlug(): string
    {
        return $this->slug;
    }

    public function setSlug(string $slug): self
    {
        $this->slug = $slug;

        return $this;
    }

    public function getSpot(): ?string
    {
        return $this->spot;
    }

    public function setSpot(?string $spot): self
    {
        $this->spot = $spot;

        return $this;
    }

    public function getContent(): ?string
    {
        return $this->content;
    }

    public function setContent(?string $content): self
    {
        $this->content = $content;

        return $this;
    }

    public function getFeaturedImage(): ?string
    {
        return $this->featuredImage;
    }

    public function setFeaturedImage(?string $featuredImage): self
    {
        $this->featuredImage = $featuredImage;

        return $this;
    }

    public function getImageCaption(): ?string
    {
        return $this->imageCaption;
    }

    public function setImageCaption(?string $imageCaption): self
    {
        $this->imageCaption = $imageCaption;

        return $this;
    }

    public function getVideoUrl(): ?string
    {
        return $this->videoUrl;
    }

    public function setVideoUrl(?string $videoUrl): self
    {
        $this->videoUrl = $videoUrl;

        return $this;
    }

    public function getVideoEmbed(): ?string
    {
        return $this->videoEmbed;
    }

    public function setVideoEmbed(?string $videoEmbed): self
    {
        $this->videoEmbed = $videoEmbed;

        return $this;
    }

    public function getGallery(): ?array
    {
        return $this->gallery;
    }

    public function setGallery(?array $gallery): self
    {
        $this->gallery = $gallery;

        return $this;
    }

    public function getCategory(): ?Category
    {
        return $this->category;
    }

    public function setCategory(?Category $category): self
    {
        $this->category = $category;

        return $this;
    }

    public function getAuthor(): ?Author
    {
        return $this->author;
    }

    public function setAuthor(?Author $author): self
    {
        $this->author = $author;

        return $this;
    }

    /** @return Collection<int, Tag> */
    public function getTags(): Collection
    {
        return $this->tags;
    }

    public function addTag(Tag $tag): self
    {
        if (!$this->tags->contains($tag)) {
            $this->tags->add($tag);
        }

        return $this;
    }

    public function removeTag(Tag $tag): self
    {
        $this->tags->removeElement($tag);

        return $this;
    }

    public function getSource(): ?string
    {
        return $this->source;
    }

    public function setSource(?string $source): self
    {
        $this->source = $source;

        return $this;
    }

    public function getSourceUrl(): ?string
    {
        return $this->sourceUrl;
    }

    public function setSourceUrl(?string $sourceUrl): self
    {
        $this->sourceUrl = $sourceUrl;

        return $this;
    }

    public function getStatus(): string
    {
        return $this->status;
    }

    public function setStatus(string $status): self
    {
        $this->status = $status;

        return $this;
    }

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

    public function setIsBreaking(bool $isBreaking): self
    {
        $this->isBreaking = $isBreaking;

        return $this;
    }

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

    public function setIsFeatured(bool $isFeatured): self
    {
        $this->isFeatured = $isFeatured;

        return $this;
    }

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

    public function setIsHeadline(bool $isHeadline): self
    {
        $this->isHeadline = $isHeadline;

        return $this;
    }

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

    public function setIsEditorsPick(bool $isEditorsPick): self
    {
        $this->isEditorsPick = $isEditorsPick;

        return $this;
    }

    public function isAllowComments(): bool
    {
        return $this->allowComments;
    }

    public function setAllowComments(bool $allowComments): self
    {
        $this->allowComments = $allowComments;

        return $this;
    }

    public function isShowInAmp(): bool
    {
        return $this->showInAmp;
    }

    public function setShowInAmp(bool $showInAmp): self
    {
        $this->showInAmp = $showInAmp;

        return $this;
    }

    public function getSeoTitle(): ?string
    {
        return $this->seoTitle;
    }

    public function setSeoTitle(?string $seoTitle): self
    {
        $this->seoTitle = $seoTitle;

        return $this;
    }

    public function getSeoDescription(): ?string
    {
        return $this->seoDescription;
    }

    public function setSeoDescription(?string $seoDescription): self
    {
        $this->seoDescription = $seoDescription;

        return $this;
    }

    public function getFocusKeyword(): ?string
    {
        return $this->focusKeyword;
    }

    public function setFocusKeyword(?string $focusKeyword): self
    {
        $this->focusKeyword = $focusKeyword;

        return $this;
    }

    public function getSeoScore(): int
    {
        return $this->seoScore;
    }

    public function setSeoScore(int $seoScore): self
    {
        $this->seoScore = $seoScore;

        return $this;
    }

    public function getCanonicalUrl(): ?string
    {
        return $this->canonicalUrl;
    }

    public function setCanonicalUrl(?string $canonicalUrl): self
    {
        $this->canonicalUrl = $canonicalUrl;

        return $this;
    }

    public function getRobotsMeta(): string
    {
        return $this->robotsMeta;
    }

    public function setRobotsMeta(string $robotsMeta): self
    {
        $this->robotsMeta = $robotsMeta;

        return $this;
    }

    public function getViewCount(): int
    {
        return $this->viewCount;
    }

    public function setViewCount(int $viewCount): self
    {
        $this->viewCount = $viewCount;

        return $this;
    }

    public function getCommentCount(): int
    {
        return $this->commentCount;
    }

    public function setCommentCount(int $commentCount): self
    {
        $this->commentCount = $commentCount;

        return $this;
    }

    public function getShareCount(): int
    {
        return $this->shareCount;
    }

    public function setShareCount(int $shareCount): self
    {
        $this->shareCount = $shareCount;

        return $this;
    }

    public function getAgencySource(): ?string
    {
        return $this->agencySource;
    }

    public function setAgencySource(?string $agencySource): self
    {
        $this->agencySource = $agencySource;

        return $this;
    }

    public function getAgencyItemId(): ?string
    {
        return $this->agencyItemId;
    }

    public function setAgencyItemId(?string $agencyItemId): self
    {
        $this->agencyItemId = $agencyItemId;

        return $this;
    }

    public function isShareToFacebook(): bool
    {
        return $this->shareToFacebook;
    }

    public function setShareToFacebook(bool $shareToFacebook): self
    {
        $this->shareToFacebook = $shareToFacebook;

        return $this;
    }

    public function isShareToTwitter(): bool
    {
        return $this->shareToTwitter;
    }

    public function setShareToTwitter(bool $shareToTwitter): self
    {
        $this->shareToTwitter = $shareToTwitter;

        return $this;
    }

    public function isShareToTelegram(): bool
    {
        return $this->shareToTelegram;
    }

    public function setShareToTelegram(bool $shareToTelegram): self
    {
        $this->shareToTelegram = $shareToTelegram;

        return $this;
    }

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

    public function setPublishedAt(?\DateTimeImmutable $publishedAt): self
    {
        $this->publishedAt = $publishedAt;

        return $this;
    }

    public function getScheduledAt(): ?\DateTimeImmutable
    {
        return $this->scheduledAt;
    }

    public function setScheduledAt(?\DateTimeImmutable $scheduledAt): self
    {
        $this->scheduledAt = $scheduledAt;

        return $this;
    }

    public function getCreatedAt(): \DateTimeImmutable
    {
        return $this->createdAt;
    }

    public function getUpdatedAt(): \DateTimeImmutable
    {
        return $this->updatedAt;
    }

    #[ORM\PrePersist]
    public function onPrePersist(): void
    {
        $this->createdAt = new \DateTimeImmutable();
        $this->updatedAt = new \DateTimeImmutable();
    }

    #[ORM\PreUpdate]
    public function onPreUpdate(): void
    {
        $this->updatedAt = new \DateTimeImmutable();
    }
}
