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.
26 lines
668 B
26 lines
668 B
<?php namespace SocialNorm;
|
|
|
|
use SocialNorm\Exceptions\ProviderNotRegisteredException;
|
|
|
|
class ProviderRegistry
|
|
{
|
|
private $providers = [];
|
|
|
|
public function registerProvider($alias, Provider $provider)
|
|
{
|
|
$this->providers[$alias] = $provider;
|
|
}
|
|
|
|
public function getProvider($providerAlias)
|
|
{
|
|
if (! $this->hasProvider($providerAlias)) {
|
|
throw new ProviderNotRegisteredException("No provider has been registered under the alias '{$providerAlias}'");
|
|
}
|
|
return $this->providers[$providerAlias];
|
|
}
|
|
|
|
protected function hasProvider($alias)
|
|
{
|
|
return isset($this->providers[$alias]);
|
|
}
|
|
}
|
|
|