Conditions | 3 |
Paths | 1 |
Total Lines | 25 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
64 | public function __construct(Chan $chan, Closure $program, Closure $failure = null) |
||
65 | { |
||
66 | $this->chan = $chan; |
||
67 | $this->program = $program; |
||
68 | $this->failure = $failure; |
||
69 | |||
70 | $this->processor = function ($data, Context $ctx = null) { |
||
71 | async($this->program, $ctx ?? new Context(), $data)->then($this->done, $this->done); |
||
72 | }; |
||
73 | |||
74 | $this->done = function ($e = null) { |
||
75 | $this->running --; |
||
76 | |||
77 | if ($this->failure && $e instanceof Throwable) { |
||
78 | ($this->failure)($e); |
||
79 | } |
||
80 | |||
81 | $this->execute(); |
||
82 | }; |
||
83 | |||
84 | $this->close = function () { |
||
85 | $this->closing = true; |
||
86 | }; |
||
87 | |||
88 | $this->execute(); |
||
89 | } |
||
118 |