<?php

declare(strict_types=1);

namespace App\Service\OnlineRegistration;

use App\Entity\Access\Access;
use App\Entity\AccessWish\AccessWish;
use App\Service\Utils\DatesUtils;

/**
 * --- SERVICE INUTILISE POUR LE MOMENT ---.
 */
class OnlineRegistrationService
{
    /**
     * Retourne le premier AccessWish correspondant à l'année en cours, ou null si aucun n'est trouvé.
     */
    public function getCurrentAccessWish(Access $access): ?AccessWish
    {
        $currentYear = DatesUtils::new()->format('Y');

        foreach ($access->getAccessWishes() as $accessWish) {
            /** @var AccessWish $accessWish */
            if ($accessWish->getCreateDate()->format('Y') === $currentYear) {
                return $accessWish;
            }
        }

        return null;
    }
}
