Lines n/a 0 / 0
Functions and Methods n/a 0 / 0
Classes and Traits n/a 0 / 0
Name Lines Functions and Methods CRAP Classes and Traits
1<?php
2
3declare(strict_types=1);
4
5namespace Tomaj\Hermes;
6
7use Tomaj\Hermes\Handler\HandlerInterface;
8
9interface DispatcherInterface
10{
11    /**
12     * Register new handler
13     *
14     * With this method you can register new handler for selected $type.
15     * This handler will be called in background job when event
16     * of registered $type will be emitted.
17     *
18     * @return $this
19     */
20    public function registerHandler(string $type, HandlerInterface $handler): DispatcherInterface;
21
22    /**
23     * Register multiple handlers for same type.
24     *
25     * @param HandlerInterface[] $handler
26     */
27    public function registerHandlers(string $type, array $handler): DispatcherInterface;
28
29    /**
30     * Will unregister all handlers. This method is useful for testing.
31     */
32    public function unregisterAllHandlers(): DispatcherInterface;
33
34    /**
35     * Will unregister a specific handler.
36     */
37    public function unregisterHandler(string $type, HandlerInterface $handler): DispatcherInterface;
38
39    /**
40     * Basic method for background job to star listening.
41     *
42     * @param int[] $priorities
43     */
44    public function handle(array $priorities = []): void;
45}