| Total Complexity | 5 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class HandlerCollection |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var AbstractTool[]|iterable |
||
| 15 | */ |
||
| 16 | private $handlers; |
||
| 17 | |||
| 18 | public function __construct(iterable $handlers) |
||
| 19 | { |
||
| 20 | $this->handlers = $handlers; |
||
| 21 | } |
||
| 22 | |||
| 23 | public function getHandler(string $name): AbstractTool |
||
| 24 | { |
||
| 25 | foreach ($this->handlers as $handler) { |
||
| 26 | if ($name === $handler->getName()) { |
||
| 27 | return $handler; |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | throw new InvalidArgumentException(sprintf('Cannot handle tool "%s"', $name)); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return AbstractTool[]|iterable |
||
| 36 | */ |
||
| 37 | public function getCollection() |
||
| 40 | } |
||
| 41 | } |
||
| 42 |