94 lines
2.7 KiB
PHP
94 lines
2.7 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Uwil\ArcadiaApiPhpClient\Factory;
|
||
|
|
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Hydrator\BrandHydrator;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Hydrator\EmployeeHydrator;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Hydrator\IncoCompoHydrator;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Hydrator\IncoHydrator;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Hydrator\IncoShortHydrator;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Repository\BrandApiRepository;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Repository\EmployeeApiRepository;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Repository\IncoApiRepository;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Repository\IncoCompoApiRepository;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Repository\IncoShortApiRepository;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Service\ArcadiaBrandService;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Service\ArcadiaEmployeeService;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Service\ArcadiaIncoService;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Service\BrandService;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Service\EmployeeService;
|
||
|
|
use Uwil\ArcadiaApiPhpClient\Service\IncoService;
|
||
|
|
use Uwil\ArcadiaKiotaOpenApiClient\ApiClient;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @internal
|
||
|
|
*/
|
||
|
|
final class ServiceFactory
|
||
|
|
{
|
||
|
|
private ?EmployeeService $employeeService = null;
|
||
|
|
|
||
|
|
private ?IncoService $incoService = null;
|
||
|
|
|
||
|
|
private ?BrandService $brandService = null;
|
||
|
|
|
||
|
|
public function __construct(
|
||
|
|
private readonly ApiClient $apiClient
|
||
|
|
) {
|
||
|
|
}
|
||
|
|
|
||
|
|
public function createEmployeeService(): EmployeeService
|
||
|
|
{
|
||
|
|
return $this->employeeService ??= new ArcadiaEmployeeService(
|
||
|
|
new EmployeeApiRepository(
|
||
|
|
$this->apiClient,
|
||
|
|
new EmployeeHydrator()
|
||
|
|
)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function createIncoService(): IncoService
|
||
|
|
{
|
||
|
|
return $this->incoService ??= new ArcadiaIncoService(
|
||
|
|
new IncoApiRepository(
|
||
|
|
$this->apiClient,
|
||
|
|
new IncoHydrator()
|
||
|
|
),
|
||
|
|
new IncoShortApiRepository(
|
||
|
|
$this->apiClient,
|
||
|
|
new IncoShortHydrator()
|
||
|
|
),
|
||
|
|
new IncoCompoApiRepository(
|
||
|
|
$this->apiClient,
|
||
|
|
new IncoCompoHydrator()
|
||
|
|
)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function createBrandService(): BrandService
|
||
|
|
{
|
||
|
|
return $this->brandService ??= new ArcadiaBrandService(
|
||
|
|
new BrandApiRepository(
|
||
|
|
$this->apiClient,
|
||
|
|
new BrandHydrator()
|
||
|
|
)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function employeeService(): EmployeeService
|
||
|
|
{
|
||
|
|
return $this->createEmployeeService();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function incoService(): IncoService
|
||
|
|
{
|
||
|
|
return $this->createIncoService();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function brandService(): BrandService
|
||
|
|
{
|
||
|
|
return $this->createBrandService();
|
||
|
|
}
|
||
|
|
}
|