<?php
declare(strict_types=1);

namespace Autogedal\BlackFriday\Cron;

use Autogedal\BlackFriday\Model\LaunchMailer;
use Psr\Log\LoggerInterface;

class SendLaunchEmails
{
    public function __construct(private readonly LaunchMailer $mailer, private readonly LoggerInterface $logger)
    {
    }

    public function execute(): void
    {
        $result = $this->mailer->sendPending();
        if ($result['sent'] || $result['errors']) {
            $this->logger->info(sprintf('Black Friday launch emails: %d sent, %d errors', $result['sent'], $result['errors']));
        }
    }
}
