| Conditions | 10 |
| Paths | 37 |
| Total Lines | 14 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 85 | private function isValidError($payload): bool |
||
| 86 | { |
||
| 87 | if (!is_array($payload)) { |
||
| 88 | return false; |
||
| 89 | } |
||
| 90 | |||
| 91 | $headerValid = array_key_exists('jsonrpc', $payload) && $payload['jsonrpc'] === '2.0'; |
||
| 92 | $errorValid = array_key_exists('error', $payload) && is_array($payload['error']) |
||
| 93 | && array_key_exists('code', $payload['error']) && is_int($payload['error']['code']) |
||
| 94 | && array_key_exists('message', $payload['error']) && is_string($payload['error']['message']); |
||
| 95 | $idValid = array_key_exists('id', $payload); |
||
| 96 | |||
| 97 | return $headerValid && $errorValid && $idValid; |
||
| 98 | } |
||
| 99 | } |
||
| 100 |