| Conditions | 7 |
| Paths | 9 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 7 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 34 | 20 | public function response($string) |
|
| 35 | { |
||
| 36 | 20 | $decoded = json_decode(trim($string), true); |
|
| 37 | |||
| 38 | 20 | if (json_last_error() === JSON_ERROR_NONE) { |
|
| 39 | 19 | $id = isset($decoded['id']) ? $decoded['id'] : null; |
|
| 40 | |||
| 41 | 19 | if (isset($decoded['error'])) { |
|
| 42 | 1 | throw new ApiError($id, $decoded['error']); |
|
| 43 | 18 | } elseif (isset($decoded['method']) && isset($decoded['params'])) { |
|
| 44 | 14 | return new Request($id, $decoded['method'], $decoded['params']); |
|
| 45 | 5 | } elseif (isset($decoded['result'])) { |
|
| 46 | 4 | return new Response($id, $decoded['result']); |
|
| 47 | } |
||
| 48 | |||
| 49 | 1 | throw new \Exception('Response missing error/params/result'); |
|
| 50 | } |
||
| 51 | |||
| 52 | 1 | throw new \Exception('Invalid JSON'); |
|
| 53 | } |
||
| 54 | } |
||
| 55 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.