Conditions | 11 |
Paths | 3 |
Total Lines | 27 |
Code Lines | 16 |
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 |
||
41 | public function logQuery(array $query) |
||
42 | { |
||
43 | if (null === $this->logger) { |
||
44 | return; |
||
45 | } |
||
46 | |||
47 | if (isset($query['batchInsert']) && null !== $this->batchInsertTreshold && $this->batchInsertTreshold <= $query['num']) { |
||
48 | $query['data'] = '**'.$query['num'].' item(s)**'; |
||
49 | } |
||
50 | |||
51 | array_walk_recursive($query, function(&$value, $key) { |
||
|
|||
52 | if ($value instanceof \MongoBinData) { |
||
53 | $value = base64_encode($value->bin); |
||
54 | return; |
||
55 | } |
||
56 | if (is_float($value) && is_infinite($value)) { |
||
57 | $value = ($value < 0 ? '-' : '') . 'Infinity'; |
||
58 | return; |
||
59 | } |
||
60 | if (is_float($value) && is_nan($value)) { |
||
61 | $value = 'NaN'; |
||
62 | return; |
||
63 | } |
||
64 | }); |
||
65 | |||
66 | $this->logger->debug($this->prefix.json_encode($query)); |
||
67 | } |
||
68 | } |
||
69 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.