| Conditions | 9 |
| Paths | 6 |
| Total Lines | 11 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 56 | function get_by_key($data, $key, $default = null, $validate = null) |
||
| 57 | { |
||
| 58 | $out = $default; |
||
| 59 | if (is_array($data) && (is_int($key) || is_string($key)) && $key !== '' && array_key_exists($key, $data)) { |
||
| 60 | $out = $data[$key]; |
||
| 61 | } |
||
| 62 | if (! empty($validate) && is_callable($validate)) { |
||
| 63 | $out = (($validate($out) === true) ? $out : $default); |
||
| 64 | } |
||
| 65 | return $out; |
||
| 66 | } |
||
| 67 | } |
||
| 68 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.