<?php

declare(strict_types=1);

/*
 * This file is part of the VITICORE2 package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\TransactionalEmail;

use CpCreation\VitiCore\TransactionalEmail\Repository\TransactionalEmailQueueRepository;

final readonly class TransactionalEmailDueProcessor
{
    public function __construct(
        private TransactionalEmailQueueRepository $queueRepository,
    ) {
    }

    public function countDue(?\DateTimeImmutable $now = null): int
    {
        return \count($this->queueRepository->findDuePending($now ?? new \DateTimeImmutable()));
    }
}
