We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Total Complexity | 10 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | final class LifecycleHooks |
||
| 6 | { |
||
| 7 | public array $hooks = []; |
||
| 8 | |||
| 9 | public function hookInto(string|array $hooks, callable $callback): void |
||
| 14 | } |
||
| 15 | } |
||
| 16 | |||
| 17 | public function trigger(string|array $hooks, array $parameters = []): void |
||
| 18 | { |
||
| 19 | $hooks = is_array($hooks) ? $hooks : [$hooks]; |
||
| 20 | foreach ($hooks as $hook) { |
||
| 21 | if (isset($this->hooks[$hook])) { |
||
| 22 | foreach ($this->hooks[$hook] as $callback) { |
||
| 23 | if ($callback instanceof \Closure) { |
||
| 24 | $callback(...$parameters); |
||
| 25 | } |
||
| 26 | } |
||
| 27 | } |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | public function has(string $hook): bool |
||
| 34 | } |
||
| 35 | } |
||
| 36 |