| Conditions | 1 |
| Paths | 1 |
| Total Lines | 74 |
| Code Lines | 43 |
| 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 |
||
| 50 | public function methodNamesData(): array |
||
| 51 | { |
||
| 52 | $defaultArgs = [ |
||
| 53 | [ |
||
| 54 | 'conditions' => 'field1 => :value:', |
||
| 55 | 'binds' => ['value' => 1], |
||
| 56 | ], |
||
| 57 | ]; |
||
| 58 | |||
| 59 | return [ |
||
| 60 | [ |
||
| 61 | 'methodName' => 'findFirst', |
||
| 62 | 'args' => $defaultArgs, |
||
| 63 | 'returnData' => $this->createMock(Model::class), |
||
| 64 | ], |
||
| 65 | [ |
||
| 66 | 'methodName' => 'findFirst', |
||
| 67 | 'args' => $defaultArgs, |
||
| 68 | 'returnData' => false, |
||
| 69 | ], |
||
| 70 | [ |
||
| 71 | 'methodName' => 'find', |
||
| 72 | 'args' => $defaultArgs, |
||
| 73 | 'returnData' => $this->createMock(SimpleResultset::class), |
||
| 74 | ], |
||
| 75 | [ |
||
| 76 | 'methodName' => 'query', |
||
| 77 | 'args' => [$this->createMock(DiInterface::class)], |
||
| 78 | 'returnData' => $this->createMock(Criteria::class), |
||
| 79 | ], |
||
| 80 | [ |
||
| 81 | 'methodName' => 'count', |
||
| 82 | 'args' => $defaultArgs, |
||
| 83 | 'returnData' => 10, |
||
| 84 | ], |
||
| 85 | [ |
||
| 86 | 'methodName' => 'sum', |
||
| 87 | 'args' => $defaultArgs, |
||
| 88 | 'returnData' => null, |
||
| 89 | ], |
||
| 90 | [ |
||
| 91 | 'methodName' => 'sum', |
||
| 92 | 'args' => $defaultArgs, |
||
| 93 | 'returnData' => '11.4', |
||
| 94 | ], |
||
| 95 | [ |
||
| 96 | 'methodName' => 'average', |
||
| 97 | 'args' => $defaultArgs, |
||
| 98 | 'returnData' => null, |
||
| 99 | ], |
||
| 100 | [ |
||
| 101 | 'methodName' => 'average', |
||
| 102 | 'args' => $defaultArgs, |
||
| 103 | 'returnData' => '20.42', |
||
| 104 | ], |
||
| 105 | [ |
||
| 106 | 'methodName' => 'minimum', |
||
| 107 | 'args' => $defaultArgs, |
||
| 108 | 'returnData' => null, |
||
| 109 | ], |
||
| 110 | [ |
||
| 111 | 'methodName' => 'minimum', |
||
| 112 | 'args' => $defaultArgs, |
||
| 113 | 'returnData' => '2019-01-01', |
||
| 114 | ], |
||
| 115 | [ |
||
| 116 | 'methodName' => 'maximum', |
||
| 117 | 'args' => $defaultArgs, |
||
| 118 | 'returnData' => null, |
||
| 119 | ], |
||
| 120 | [ |
||
| 121 | 'methodName' => 'maximum', |
||
| 122 | 'args' => $defaultArgs, |
||
| 123 | 'returnData' => '2019-01-01', |
||
| 124 | ], |
||
| 128 |