Files
breadcrumb-the-shire/lib/Service/Mail/MailServicesFactory.php
2026-03-06 00:44:52 +01:00

42 lines
1.1 KiB
PHP

<?php
namespace MintyPHP\Service\Mail;
use MintyPHP\Repository\Mail\MailLogRepositoryInterface;
use MintyPHP\Service\Settings\SettingsSmtpGateway;
class MailServicesFactory
{
private ?MailService $mailService = null;
private ?MailLogService $mailLogService = null;
public function __construct(
private readonly MailRepositoryFactory $mailRepositoryFactory,
private readonly SettingsSmtpGateway $settingsSmtpGateway
) {
}
public function createMailLogRepository(): MailLogRepositoryInterface
{
return $this->mailRepositoryFactory->createMailLogRepository();
}
public function createMailService(): MailService
{
return $this->mailService ??= new MailService(
$this->createMailLogRepository(),
$this->createSettingsSmtpGateway()
);
}
public function createMailLogService(): MailLogService
{
return $this->mailLogService ??= new MailLogService($this->createMailLogRepository());
}
private function createSettingsSmtpGateway(): SettingsSmtpGateway
{
return $this->settingsSmtpGateway;
}
}