<?php
declare(strict_types=1);

namespace Favo\Services;

use PDO;

/**
 * Auto-unlock bridge used after a successful loyalty EARN.
 *
 * This service intentionally does not mutate the loyalty balance.
 * UnlockService::evaluate() creates only missing reward entitlement cycles.
 */
final class AutoUnlockService
{
    public function __construct(private PDO $db)
    {
    }

    public function evaluateAfterEarn(
        int $customerId,
        int $merchantId,
        ?int $programId = null,
        ?int $actorId = null
    ): array {
        $unlock = new UnlockService($this->db);

        return $unlock->evaluate(
            $customerId,
            $merchantId,
            $programId,
            $actorId
        );
    }
}
