29 lines
659 B
PHP
29 lines
659 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\WbService;
|
|
|
|
use App\Contracts\WbSyncFactoryInterface;
|
|
use App\Contracts\WbSyncInterface;
|
|
use App\Enums\WbEndpoint;
|
|
use App\Exceptions\WbServiceException;
|
|
|
|
final readonly class WbSyncFactory implements WbSyncFactoryInterface
|
|
{
|
|
public function __construct(
|
|
/** @var array<string, WbSyncInterface> */
|
|
private array $services
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* @throws WbServiceException
|
|
*/
|
|
public function make(WbEndpoint $type): WbSyncInterface
|
|
{
|
|
return $this->services[$type->name]
|
|
?? throw new WbServiceException("unknown sync type $type->name");
|
|
}
|
|
}
|