<?php

declare(strict_types=1);

namespace App\Module\Absence\Infrastructure\Doctrine;

use App\Module\Absence\Domain\Entity\AbsencePolicy;
use App\Module\Absence\Domain\Enum\AbsenceType;
use App\Module\Absence\Domain\Repository\AbsencePolicyRepositoryInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<AbsencePolicy>
 */
class DoctrineAbsencePolicyRepository extends ServiceEntityRepository implements AbsencePolicyRepositoryInterface
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, AbsencePolicy::class);
    }

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

    public function findOneByType(AbsenceType $type): ?AbsencePolicy
    {
        return $this->findOneBy(['type' => $type]);
    }
}
