instances added god may help
This commit is contained in:
44
lib/Service/Mail/MailServicesFactory.php
Normal file
44
lib/Service/Mail/MailServicesFactory.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Service\Mail;
|
||||
|
||||
use MintyPHP\Repository\Mail\MailLogRepository;
|
||||
use MintyPHP\Service\Settings\SettingGateway;
|
||||
use MintyPHP\Service\Settings\SettingServicesFactory;
|
||||
|
||||
class MailServicesFactory
|
||||
{
|
||||
private ?MailLogRepository $mailLogRepository = null;
|
||||
private ?SettingServicesFactory $settingServicesFactory = null;
|
||||
private ?SettingGateway $settingGateway = null;
|
||||
private ?MailService $mailService = null;
|
||||
private ?MailLogService $mailLogService = null;
|
||||
|
||||
public function createMailLogRepository(): MailLogRepository
|
||||
{
|
||||
return $this->mailLogRepository ??= new MailLogRepository();
|
||||
}
|
||||
|
||||
public function createMailService(): MailService
|
||||
{
|
||||
return $this->mailService ??= new MailService(
|
||||
$this->createMailLogRepository(),
|
||||
$this->createSettingGateway()
|
||||
);
|
||||
}
|
||||
|
||||
public function createMailLogService(): MailLogService
|
||||
{
|
||||
return $this->mailLogService ??= new MailLogService($this->createMailLogRepository());
|
||||
}
|
||||
|
||||
private function createSettingGateway(): SettingGateway
|
||||
{
|
||||
return $this->settingGateway ??= $this->settingServicesFactory()->createSettingGateway();
|
||||
}
|
||||
|
||||
private function settingServicesFactory(): SettingServicesFactory
|
||||
{
|
||||
return $this->settingServicesFactory ??= new SettingServicesFactory();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user