Conditions | 10 |
Paths | 2 |
Total Lines | 23 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
47 | public function logQuery(array $query) |
||
48 | { |
||
49 | if (isset($query['batchInsert']) && null !== $this->batchInsertThreshold && $this->batchInsertThreshold <= $query['num']) { |
||
50 | $query['data'] = '**'.$query['num'].' item(s)**'; |
||
51 | } |
||
52 | |||
53 | array_walk_recursive($query, function(&$value, $key) { |
||
|
|||
54 | if ($value instanceof \MongoBinData) { |
||
55 | $value = base64_encode($value->bin); |
||
56 | return; |
||
57 | } |
||
58 | if (is_float($value) && is_infinite($value)) { |
||
59 | $value = ($value < 0 ? '-' : '') . 'Infinity'; |
||
60 | return; |
||
61 | } |
||
62 | if (is_float($value) && is_nan($value)) { |
||
63 | $value = 'NaN'; |
||
64 | return; |
||
65 | } |
||
66 | }); |
||
67 | |||
68 | $this->logger->info($this->prefix, $query); |
||
69 | } |
||
70 | } |
||
71 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.