| Conditions | 10 |
| Paths | 13 |
| Total Lines | 34 |
| Code Lines | 17 |
| 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 |
||
| 18 | public static function checkType($vars) |
||
| 19 | { |
||
| 20 | if (!is_array($vars)) { |
||
| 21 | return false; |
||
| 22 | } |
||
| 23 | |||
| 24 | foreach ($vars as $var) { |
||
| 25 | if (!is_array($var)) { |
||
| 26 | return false; |
||
| 27 | } |
||
| 28 | |||
| 29 | if (!(!empty($var['type']) && isset($var['data']))) { |
||
| 30 | return false; |
||
| 31 | } |
||
| 32 | |||
| 33 | if (!is_string($var['type'])) { |
||
| 34 | return false; |
||
| 35 | } |
||
| 36 | |||
| 37 | if ($var['type'] === 'int') { |
||
| 38 | $var['type'] = 'integer'; |
||
| 39 | } |
||
| 40 | |||
| 41 | if ($var['type'] === 'float') { |
||
| 42 | $var['type'] = 'double'; |
||
| 43 | } |
||
| 44 | |||
| 45 | if (gettype($var['data']) !== $var['type']) { |
||
| 46 | return false; |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | return true; |
||
| 51 | } |
||
| 52 | |||
| 65 |
This check looks for function calls that miss required arguments.