Conditions | 5 |
Paths | 9 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
52 | 6 | public function getOrSend($callable, $params = []) |
|
53 | { |
||
54 | 6 | if (!is_null($this->result)) { |
|
55 | 1 | return $this->result; |
|
56 | } |
||
57 | |||
58 | 5 | if (is_callable($callable)) { |
|
59 | 3 | $callable = call_user_func_array($callable, $params); |
|
60 | } |
||
61 | |||
62 | 5 | if (is_a($callable, Response::class)) { |
|
63 | 3 | $response = $callable; |
|
64 | } |
||
65 | |||
66 | 5 | if (isset($response)) { |
|
67 | 3 | throw new HttpResponseException($response); |
|
68 | } |
||
69 | |||
70 | 2 | throw new \InvalidArgumentException('You should provide a valid http response.'); |
|
71 | } |
||
72 | |||
89 |