Files
test_ea/laravel/app/Services/WbService/WbSyncFactory.php
2026-02-15 01:34:17 +07:00

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");
}
}