<?php
declare(strict_types=1);

namespace App\ApiResources\Access;

use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\ApiResources\ApiResourcesInterface;
use JetBrains\PhpStorm\Pure;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Classe resource qui contient les champs d'un compte admin
 */
#[ApiResource(
    collectionOperations:[],
    itemOperations: [
        'get' => [
            'method' => 'GET',
            'path' => '/admin/{id}',
            'defaults' => ['id' => 0]
        ],
        'put' => [
            'method' => 'PUT',
            'path' => '/admin/{id}',
            'defaults' => ['id' => 0]
        ]
    ]
)]
class AdminAccess implements ApiResourcesInterface
{
    #[ApiProperty(identifier: true)]
    public ?int $id = null;

    private ?string $username = null;

    #[Assert\Email(message: 'invalid-email-format', mode: 'strict')]
    private ?string $email = null;


    #[Pure] public function __construct()
    {
    }

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

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

        return $this;
    }

    public function getUsername(): ?string
    {
        return $this->username;
    }

    public function setUsername(?string $username): self
    {
        $this->username = $username;

        return $this;
    }


    public function getEmail(): ?string
    {
        return $this->email;
    }

    public function setEmail(?string $email): self
    {
        $this->email = $email;

        return $this;
    }
}
