Conditions | 5 |
Paths | 9 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
60 | 5 | public function getOrSend($callable, $params = []) |
|
61 | { |
||
62 | 5 | if (! is_null($this->result)) { |
|
63 | 1 | return $this->result; |
|
64 | } |
||
65 | |||
66 | 4 | if (is_callable($callable)) { |
|
67 | 2 | $response = call_user_func_array($callable, $params); |
|
68 | } |
||
69 | |||
70 | 4 | if (is_a($callable, Response::class)) { |
|
71 | 1 | $response = $callable; |
|
72 | } |
||
73 | |||
74 | 4 | if(isset($response)) { |
|
75 | 3 | throw new HttpResponseException($response); |
|
76 | } |
||
77 | |||
78 | 1 | throw new \InvalidArgumentException('You should provide a response.'); |
|
79 | } |
||
80 | } |