| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Endroid\QrCode\Builder; |
| 6 |
|
| 7 |
final class BuilderRegistry implements BuilderRegistryInterface |
| 8 |
{ |
| 9 |
/** @var array<BuilderInterface> */ |
| 10 |
private array $builders = []; |
| 11 |
|
| 12 |
public function getBuilder(string $name): BuilderInterface |
| 13 |
{ |
| 14 |
if (!isset($this->builders[$name])) { |
| 15 |
throw new \Exception(sprintf('Builder with name "%s" not available from registry', $name)); |
| 16 |
} |
| 17 |
|
| 18 |
return $this->builders[$name]; |
| 19 |
} |
| 20 |
|
| 21 |
public function addBuilder(string $name, BuilderInterface $builder): void |
| 22 |
{ |
| 23 |
$this->builders[$name] = $builder; |
| 24 |
} |
| 25 |
} |