Conditions | 3 |
Paths | 1 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Tests | 18 |
CRAP Score | 3.009 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
24 | 1 | public function call(ObservableInterface $observable): State |
|
25 | { |
||
26 | 1 | $state = new State(); |
|
27 | $this->kernel->execute(function () use ($observable, $state) { |
||
28 | 1 | $state->onNext(State::STARTED); |
|
29 | 1 | yield; |
|
30 | 1 | $observableWhile = observableWhile($observable); |
|
31 | 1 | $state->onNext(State::WAITING); |
|
32 | /** @var Call $call */ |
||
33 | 1 | while ($call = (yield $observableWhile->get())) { |
|
34 | try { |
||
35 | 1 | $state->onNext(State::BUSY); |
|
36 | 1 | $callable = $call->getCallable(); |
|
37 | 1 | $arguments = $call->getArguments(); |
|
38 | 1 | $value = yield $callable(...$arguments); |
|
39 | 1 | $call->resolve($value); |
|
40 | } catch (\Throwable $et) { |
||
41 | $call->reject($et); |
||
42 | 1 | } finally { |
|
43 | 1 | unset($callable, $arguments, $call); |
|
44 | 1 | $state->onNext(State::WAITING); |
|
45 | } |
||
46 | } |
||
47 | 1 | $state->onNext(State::DONE); |
|
48 | 1 | }); |
|
49 | |||
50 | 1 | return $state; |
|
51 | } |
||
52 | } |
||
53 |