Total Complexity | 4 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
6 | class Hermes |
||
7 | { |
||
8 | const BINARY = 'hermes'; |
||
9 | |||
10 | /** |
||
11 | * @param string $event |
||
12 | * @param null|string $payload |
||
13 | * @return int |
||
14 | */ |
||
15 | public static function dispatch(string $event, ?string $payload = null): int |
||
16 | { |
||
17 | $command = Hermes::BINARY . " dispatch $event"; |
||
18 | if (!empty($payload)) { |
||
19 | $command .= " $payload"; |
||
20 | } |
||
21 | |||
22 | $process = new Process($command); |
||
23 | $process->enableOutput(); |
||
24 | $process->setTty(true); |
||
25 | |||
26 | return $process->run(); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param string $event |
||
31 | * @param null|string $payload |
||
32 | * @return int |
||
33 | */ |
||
34 | public static function reply(string $event, ?string $payload = null): int |
||
46 | } |
||
47 | } |
||
48 |