| Total Complexity | 5 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 61.53% |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | final class StaticDispatcher implements Dispatcher |
||
| 16 | { |
||
| 17 | private static $instance; |
||
| 18 | private $handlers; |
||
| 19 | private $dispatcher; |
||
| 20 | |||
| 21 | 1 | private function __construct() |
|
| 22 | { |
||
| 23 | 1 | $this->handlers = new HandlerMap(); |
|
| 24 | 1 | $this->dispatcher = new SignalDispatcher($this->handlers); |
|
| 25 | 1 | } |
|
| 26 | |||
| 27 | /** |
||
| 28 | * @return self |
||
| 29 | */ |
||
| 30 | 1 | public static function instance(): self |
|
| 31 | { |
||
| 32 | 1 | if (null === self::$instance) { |
|
| 33 | 1 | self::$instance = new self(); |
|
| 34 | } |
||
| 35 | |||
| 36 | 1 | return self::$instance; |
|
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param string $signal |
||
| 41 | * @param callable $action |
||
| 42 | * |
||
| 43 | * @return void |
||
| 44 | */ |
||
| 45 | public function register(string $signal, callable $action): void |
||
| 46 | { |
||
| 47 | $this->handlers->register($signal, $action); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * {@inheritdoc} |
||
| 52 | */ |
||
| 53 | public function dispatch(string $signal, ...$arguments): Task |
||
| 56 | } |
||
| 57 | } |
||
| 58 |