<?php

declare(strict_types=1);

namespace App\Module\Integration\Domain\Entity;

use App\Module\Integration\Infrastructure\Doctrine\DoctrineBookStackConfigurationRepository;
use App\Shared\Domain\Attribute\Auditable;
use App\Shared\Domain\Contract\BlamableInterface;
use App\Shared\Domain\Contract\TimestampableInterface;
use App\Shared\Domain\Trait\TimestampableBlamableTrait;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

#[Auditable]
#[ORM\Entity(repositoryClass: DoctrineBookStackConfigurationRepository::class)]
class BookStackConfiguration implements TimestampableInterface, BlamableInterface
{
    use TimestampableBlamableTrait;

    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\Column(length: 255, nullable: true)]
    #[Assert\Url]
    private ?string $url = null;

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

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

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

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

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

        return $this;
    }

    public function getEncryptedTokenId(): ?string
    {
        return $this->encryptedTokenId;
    }

    public function setEncryptedTokenId(?string $encryptedTokenId): static
    {
        $this->encryptedTokenId = $encryptedTokenId;

        return $this;
    }

    public function getEncryptedTokenSecret(): ?string
    {
        return $this->encryptedTokenSecret;
    }

    public function setEncryptedTokenSecret(?string $encryptedTokenSecret): static
    {
        $this->encryptedTokenSecret = $encryptedTokenSecret;

        return $this;
    }

    public function hasToken(): bool
    {
        return null !== $this->encryptedTokenId && null !== $this->encryptedTokenSecret;
    }
}
