| Conditions | 1 |
| Paths | 1 |
| Total Lines | 76 |
| Code Lines | 53 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 12 | public function invalidResponseBodyProvider() |
||
| 13 | { |
||
| 14 | return [ |
||
| 15 | 'empty body' => [(object)null], |
||
| 16 | 'only version' => [(object)['jsonrpc' => '2.0']], |
||
| 17 | 'invalid version' => [(object)['jsonrpc' => '1.1']], |
||
| 18 | 'only result' => [(object)['result' => (object)['success' => true]]], |
||
| 19 | 'only id' => [(object)['id' => 1234]], |
||
| 20 | 'result and id' => [(object)['result' => (object)['success' => true], 'id' => 1234]], |
||
| 21 | 'result and id and invalid version' => [ |
||
| 22 | (object)[ |
||
| 23 | 'jsonrpc' => '1.1', |
||
| 24 | 'result' => (object)['success' => true], |
||
| 25 | 'id' => 1234, |
||
| 26 | ], |
||
| 27 | ], |
||
| 28 | 'both result and error present' => [ |
||
| 29 | (object)[ |
||
| 30 | 'jsonrpc' => '2.0', |
||
| 31 | 'result' => (object)['success' => true], |
||
| 32 | 'id' => 1234, |
||
| 33 | 'error' => (object)[ |
||
| 34 | 'code' => JsonRpcErrorInterface::INTERNAL_ERROR, |
||
| 35 | 'message' => 'Test error', |
||
| 36 | ], |
||
| 37 | ], |
||
| 38 | ], |
||
| 39 | 'error is not an object' => [ |
||
| 40 | (object)[ |
||
| 41 | 'jsonrpc' => '2.0', |
||
| 42 | 'id' => 1234, |
||
| 43 | 'error' => [ |
||
| 44 | JsonRpcErrorInterface::INTERNAL_ERROR, |
||
| 45 | 'Test error', |
||
| 46 | ], |
||
| 47 | ], |
||
| 48 | ], |
||
| 49 | 'no error code' => [ |
||
| 50 | (object)[ |
||
| 51 | 'jsonrpc' => '2.0', |
||
| 52 | 'id' => 1234, |
||
| 53 | 'error' => (object)[ |
||
| 54 | 'message' => 'Test error', |
||
| 55 | ], |
||
| 56 | ], |
||
| 57 | ], |
||
| 58 | 'code is not an int' => [ |
||
| 59 | (object)[ |
||
| 60 | 'jsonrpc' => '2.0', |
||
| 61 | 'id' => 1234, |
||
| 62 | 'error' => (object)[ |
||
| 63 | 'code' => 'string', |
||
| 64 | ], |
||
| 65 | ], |
||
| 66 | ], |
||
| 67 | 'no error message' => [ |
||
| 68 | (object)[ |
||
| 69 | 'jsonrpc' => '2.0', |
||
| 70 | 'id' => 1234, |
||
| 71 | 'error' => (object)[ |
||
| 72 | 'code' => JsonRpcErrorInterface::INTERNAL_ERROR, |
||
| 73 | ], |
||
| 74 | ], |
||
| 75 | ], |
||
| 76 | 'message is not a string' => [ |
||
| 77 | (object)[ |
||
| 78 | 'jsonrpc' => '2.0', |
||
| 79 | 'id' => 1234, |
||
| 80 | 'error' => (object)[ |
||
| 81 | 'code' => 1, |
||
| 82 | 'message' => [], |
||
| 83 | ], |
||
| 84 | ], |
||
| 85 | ], |
||
| 86 | ]; |
||
| 87 | } |
||
| 88 | |||
| 141 |