Proje dosyaları eklendi
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Serp;
|
||||
|
||||
use App\Serp\Contracts\SerpProvider;
|
||||
use App\Serp\Exceptions\ProviderConfigurationException;
|
||||
|
||||
final class SerpProviderRegistry
|
||||
{
|
||||
private array $providers = [];
|
||||
|
||||
public function register(SerpProvider $provider): void
|
||||
{
|
||||
$this->providers[$provider->key()] = $provider;
|
||||
}
|
||||
|
||||
public function resolve(?string $key = null): SerpProvider
|
||||
{
|
||||
$key = $key ?: config('serp.provider');
|
||||
if (! $key || ! isset($this->providers[$key])) {
|
||||
throw new ProviderConfigurationException('Unknown provider.');
|
||||
}
|
||||
|
||||
return $this->providers[$key];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user