<?php

declare(strict_types=1);

namespace App\Entity\Tenant;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'horoscopes')]
#[ORM\UniqueConstraint(name: 'uk_sign_date', columns: ['sign', 'horoscope_date'])]
#[ORM\HasLifecycleCallbacks]
class Horoscope
{
    public const SIGNS = [
        'koc' => ['name' => 'Koç', 'icon' => '♈', 'date_range' => '21 Mart - 19 Nisan', 'element' => 'Ateş', 'order' => 1],
        'boga' => ['name' => 'Boğa', 'icon' => '♉', 'date_range' => '20 Nisan - 20 Mayıs', 'element' => 'Toprak', 'order' => 2],
        'ikizler' => ['name' => 'İkizler', 'icon' => '♊', 'date_range' => '21 Mayıs - 20 Haziran', 'element' => 'Hava', 'order' => 3],
        'yengec' => ['name' => 'Yengeç', 'icon' => '♋', 'date_range' => '21 Haziran - 22 Temmuz', 'element' => 'Su', 'order' => 4],
        'aslan' => ['name' => 'Aslan', 'icon' => '♌', 'date_range' => '23 Temmuz - 22 Ağustos', 'element' => 'Ateş', 'order' => 5],
        'basak' => ['name' => 'Başak', 'icon' => '♍', 'date_range' => '23 Ağustos - 22 Eylül', 'element' => 'Toprak', 'order' => 6],
        'terazi' => ['name' => 'Terazi', 'icon' => '♎', 'date_range' => '23 Eylül - 22 Ekim', 'element' => 'Hava', 'order' => 7],
        'akrep' => ['name' => 'Akrep', 'icon' => '♏', 'date_range' => '23 Ekim - 21 Kasım', 'element' => 'Su', 'order' => 8],
        'yay' => ['name' => 'Yay', 'icon' => '♐', 'date_range' => '22 Kasım - 21 Aralık', 'element' => 'Ateş', 'order' => 9],
        'oglak' => ['name' => 'Oğlak', 'icon' => '♑', 'date_range' => '22 Aralık - 19 Ocak', 'element' => 'Toprak', 'order' => 10],
        'kova' => ['name' => 'Kova', 'icon' => '♒', 'date_range' => '20 Ocak - 18 Şubat', 'element' => 'Hava', 'order' => 11],
        'balik' => ['name' => 'Balık', 'icon' => '♓', 'date_range' => '19 Şubat - 20 Mart', 'element' => 'Su', 'order' => 12],
    ];

    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(type: Types::INTEGER)]
    private ?int $id = null;

    #[ORM\Column(type: Types::STRING, length: 20)]
    private string $sign;

    #[ORM\Column(type: Types::DATE_IMMUTABLE)]
    private \DateTimeImmutable $horoscopeDate;

    #[ORM\Column(type: Types::TEXT)]
    private string $content;

    #[ORM\Column(type: Types::STRING, length: 20, nullable: true)]
    private ?string $loveRating = null;

    #[ORM\Column(type: Types::STRING, length: 20, nullable: true)]
    private ?string $careerRating = null;

    #[ORM\Column(type: Types::STRING, length: 20, nullable: true)]
    private ?string $healthRating = null;

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

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

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

    #[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
    private \DateTimeImmutable $createdAt;

    #[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
    private \DateTimeImmutable $updatedAt;

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

    public function getSign(): string { return $this->sign; }
    public function setSign(string $sign): self { $this->sign = $sign; return $this; }

    public function getSignName(): string
    {
        return self::SIGNS[$this->sign]['name'] ?? $this->sign;
    }

    public function getSignIcon(): string
    {
        return self::SIGNS[$this->sign]['icon'] ?? '';
    }

    public function getSignDateRange(): string
    {
        return self::SIGNS[$this->sign]['date_range'] ?? '';
    }

    public function getSignElement(): string
    {
        return self::SIGNS[$this->sign]['element'] ?? '';
    }

    public function getHoroscopeDate(): \DateTimeImmutable { return $this->horoscopeDate; }
    public function setHoroscopeDate(\DateTimeImmutable $horoscopeDate): self { $this->horoscopeDate = $horoscopeDate; return $this; }

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

    public function getLoveRating(): ?string { return $this->loveRating; }
    public function setLoveRating(?string $loveRating): self { $this->loveRating = $loveRating; return $this; }

    public function getCareerRating(): ?string { return $this->careerRating; }
    public function setCareerRating(?string $careerRating): self { $this->careerRating = $careerRating; return $this; }

    public function getHealthRating(): ?string { return $this->healthRating; }
    public function setHealthRating(?string $healthRating): self { $this->healthRating = $healthRating; return $this; }

    public function getLuckyNumber(): ?string { return $this->luckyNumber; }
    public function setLuckyNumber(?string $luckyNumber): self { $this->luckyNumber = $luckyNumber; return $this; }

    public function getLuckyColor(): ?string { return $this->luckyColor; }
    public function setLuckyColor(?string $luckyColor): self { $this->luckyColor = $luckyColor; return $this; }

    public function getStatus(): string { return $this->status; }
    public function setStatus(string $status): self { $this->status = $status; 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();
    }
}
