Conditions | 4 |
Paths | 4 |
Total Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 4.0039 |
Changes | 0 |
1 | <?php |
||
23 | 9 | public function __call($method, $params) |
|
24 | { |
||
25 | 9 | $pipeline = new Pipeline(app()); |
|
26 | |||
27 | 9 | if (!is_string($this->callable)) { |
|
28 | $core = (function ($params) use ($method) { |
||
29 | try { |
||
30 | 4 | return $this->$method(...$params); |
|
31 | 1 | } catch (\Throwable $e) { |
|
32 | 1 | return $e; |
|
33 | } |
||
34 | 6 | })->bindTo($this->callable, $this->callable); |
|
35 | } else { |
||
36 | $core = function ($params) use ($method) { |
||
37 | 1 | return call_user_func_array([$this->callable, $method], $params); |
|
38 | 3 | }; |
|
39 | } |
||
40 | |||
41 | $result = $pipeline |
||
42 | 9 | ->via('handle') |
|
43 | 9 | ->send($params) |
|
44 | 9 | ->through($this->middlewares) |
|
45 | 9 | ->then($core); |
|
46 | |||
47 | 9 | if ($result instanceof \Throwable) { |
|
48 | throw $result; |
||
49 | } else { |
||
50 | 9 | return $result; |
|
51 | } |
||
52 | } |
||
53 | } |
||
54 |