Conditions | 2 |
Paths | 1 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
33 | 3 | public function dispatch(string $signal, ...$arguments): Task |
|
34 | { |
||
35 | 3 | $handler = $this->handler($signal); |
|
36 | 3 | $channel = Channel::open($signal); |
|
37 | |||
38 | 3 | $promise = \future(function () use ($channel, $handler, $arguments) { |
|
39 | 3 | $result = $handler(...$arguments); |
|
40 | |||
41 | 2 | if ($result instanceof \Generator) { |
|
42 | 1 | $result = \coroutine($channel->attach($result)); |
|
43 | } |
||
44 | |||
45 | 2 | return $result; |
|
46 | 3 | }); |
|
47 | |||
48 | 3 | return new Task($promise, $channel); |
|
49 | } |
||
61 |