<?php

namespace Config;

use App\Services\OtpMailer;
use App\Services\OtpMailerInterface;
use CodeIgniter\Config\BaseService;

class Services extends BaseService
{
    public static function otpMailer(bool $getShared = true): OtpMailerInterface
    {
        if ($getShared) {
            return static::getSharedInstance('otpMailer');
        }

        return new OtpMailer();
    }

    /**
     * Allow tests to replace the OTP mailer (ArrayOtpMailer / FailingOtpMailer).
     */
    public static function injectOtpMailer(OtpMailerInterface $mailer): void
    {
        static::injectMock('otpMailer', $mailer);
    }
}
