<?php

declare(strict_types=1);

namespace App\Entity\Token;

use ApiPlatform\Metadata\ApiResource;
use App\Entity\Access\Access;
use App\Entity\SimulationSession\SimulationSession;
use Doctrine\ORM\Mapping as ORM;

/**
 * TODO: documenter.
 */
#[ApiResource(operations: [])]
#[ORM\Entity]
class Token
{
    #[ORM\Id]
    #[ORM\Column]
    #[ORM\GeneratedValue]
    private int $id;

    #[ORM\ManyToOne(targetEntity: Access::class, cascade: [], inversedBy: 'tokens')]
    #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
    private ?Access $access;

    #[ORM\OneToOne(targetEntity: SimulationSession::class, inversedBy: 'token', cascade: ['persist'])]
    #[ORM\JoinColumn(unique: true, nullable: true, onDelete: 'CASCADE')]
    protected ?SimulationSession $simulationSession;

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

    public function setId(int $id): self
    {
        $this->id = $id;

        return $this;
    }

    public function getAccess(): ?Access
    {
        return $this->access;
    }

    public function setAccess(?Access $access): self
    {
        $this->access = $access;

        return $this;
    }

    public function getSimulationSession(): ?SimulationSession
    {
        return $this->simulationSession;
    }

    public function setSimulationSession(?SimulationSession $simulationSession): self
    {
        $this->simulationSession = $simulationSession;

        return $this;
    }
}
