| Conditions | 5 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 37 | public function execute(string $handlerName): void |
||
| 38 | { |
||
| 39 | if (!count($this->chain)) { |
||
| 40 | throw new \Exception('The chain is empty'); |
||
| 41 | } |
||
| 42 | |||
| 43 | if (array_key_exists($handlerName, $this->chain)) { |
||
| 44 | foreach ($this->chain as $handler) { |
||
| 45 | $handler->execute(); |
||
| 46 | |||
| 47 | if (get_class($handler) === $handlerName) { |
||
| 48 | return; |
||
| 49 | } |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | throw new \InvalidArgumentException('Handler does not exist in the chain'); |
||
| 54 | } |
||
| 56 |