first commit
This commit is contained in:
28
laravel/app/Services/WbService/WbSyncFactory.php
Normal file
28
laravel/app/Services/WbService/WbSyncFactory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user