31 lines
689 B
PHP
31 lines
689 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace External\HannahBundle\SAP\Util;
|
|
|
|
use External\HannahBundle\SAP\Exception\SAPException;
|
|
use External\HannahBundle\SAP\Synchronizer\SynchronizerInterface;
|
|
use Symfony\Component\DependencyInjection\ServiceLocator;
|
|
|
|
class SAPLocator
|
|
{
|
|
private $locator;
|
|
|
|
public function __construct(ServiceLocator $locator)
|
|
{
|
|
$this->locator = $locator;
|
|
}
|
|
|
|
public function get(string $type): SynchronizerInterface
|
|
{
|
|
if (!$this->locator->has($type)) {
|
|
throw new SAPException(
|
|
sprintf('Unknown synchronizer type: %s', $type)
|
|
);
|
|
}
|
|
|
|
return $this->locator->get($type);
|
|
}
|
|
}
|