Conditions | 6 |
Paths | 5 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 3 |
CRAP Score | 16.6682 |
Changes | 0 |
1 | <?php |
||
34 | 16 | public function getResponse(array $request, array $params = []) |
|
35 | { |
||
36 | 16 | if (empty($request['url']) || empty($request['method']) || empty($request['code'])) { |
|
37 | throw new Exception('Request url, method or success_code is missing'); |
||
38 | } |
||
39 | |||
40 | 16 | $response = Curl::getResponse($this->host, $request['url'], $request['method'], $this->token, $params); |
|
|
|||
41 | |||
42 | if (isset($response['debug'])) { |
||
43 | Debuger::dump(['host' => $this->host, 'request' => $request, 'params' => $params, 'response' => $response]); |
||
44 | } |
||
45 | |||
46 | if ($response['status'] != $request['code']) { |
||
47 | throw new Exception($response['message'], $response['status']); |
||
48 | } |
||
49 | |||
50 | return $response; |
||
51 | } |
||
52 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: