<?php

declare(strict_types=1);

namespace App\Entity\Person;

use ApiPlatform\Metadata\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

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

    #[Assert\NotNull]
    #[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'allowedIps')]
    private ?Person $person;

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

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

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

        return $this;
    }

    public function getPerson(): ?Person
    {
        return $this->person;
    }

    public function setPerson(?Person $person): self
    {
        $this->person = $person;

        return $this;
    }

    public function getIpOrRange(): ?string
    {
        return $this->ipOrRange;
    }

    public function setIpOrRange(?string $ipOrRange): self
    {
        $this->ipOrRange = $ipOrRange;

        return $this;
    }
}
