datatable.directory codebase
https://datatable.directory/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
716 B
27 lines
716 B
<?php namespace SocialNorm;
|
|
|
|
use SocialNorm\Exceptions\ProviderNotRegisteredException;
|
|
|
|
class ProviderRegistry
|
|
{
|
|
/** @var Provider[] */
|
|
private $providers = [];
|
|
|
|
public function registerProvider(string $alias, Provider $provider)
|
|
{
|
|
$this->providers[$alias] = $provider;
|
|
}
|
|
|
|
public function getProvider(string $providerAlias)
|
|
{
|
|
if (! $this->hasProvider($providerAlias)) {
|
|
throw new ProviderNotRegisteredException("No provider has been registered under the alias '{$providerAlias}'");
|
|
}
|
|
return $this->providers[$providerAlias];
|
|
}
|
|
|
|
protected function hasProvider(string $alias)
|
|
{
|
|
return isset($this->providers[$alias]);
|
|
}
|
|
}
|
|
|