| Conditions | 1 |
| Paths | 1 |
| Total Lines | 57 |
| Code Lines | 36 |
| 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 |
||
| 127 | public function validNamedArgsListProvider() |
||
| 128 | { |
||
| 129 | return [ |
||
| 130 | 'n: complete' => [ |
||
| 131 | 'Bob is 65 years old and has 101 cats.', |
||
| 132 | '{name} is {age} years old and has {n} cats.', |
||
| 133 | [ |
||
| 134 | 'name' => 'Bob', |
||
| 135 | 'age' => 65, |
||
| 136 | 'n' => 101 |
||
| 137 | ], |
||
| 138 | ], |
||
| 139 | 'n: complete with numeric index' => [ |
||
| 140 | 'Bob is 65 years old and has 101 cats.', |
||
| 141 | '{name} is {age} years old and has {7} cats.', |
||
| 142 | [ |
||
| 143 | 'name' => 'Bob', |
||
| 144 | 'age' => 65, |
||
| 145 | 7 => 101 |
||
| 146 | ], |
||
| 147 | ], |
||
| 148 | 'n: missing value for placeholder' => [ |
||
| 149 | 'Bob is 65 years old and has {n} cats.', |
||
| 150 | '{name} is {age} years old and has {n} cats.', |
||
| 151 | [ |
||
| 152 | 'name' => 'Bob', |
||
| 153 | 'age' => 65, |
||
| 154 | ], |
||
| 155 | ], |
||
| 156 | 'n: complete with some empty value' => [ |
||
| 157 | 'Bob is 65 years old and has cats.', |
||
| 158 | '{name} is {age} years old and has {n} cats.', |
||
| 159 | [ |
||
| 160 | 'name' => 'Bob', |
||
| 161 | 'age' => 65, |
||
| 162 | 'n' => '' |
||
| 163 | ], |
||
| 164 | ], |
||
| 165 | 'n: complete with some null values' => [ |
||
| 166 | 'Bob is 65 years old and has cats.', |
||
| 167 | '{name} is {age} years old and has {n} cats.', |
||
| 168 | [ |
||
| 169 | 'name' => 'Bob', |
||
| 170 | 'age' => 65, |
||
| 171 | 'n' => null |
||
| 172 | ], |
||
| 173 | ], |
||
| 174 | 'n: class implementing IConvertibleToString' => [ |
||
| 175 | 'x = (-1, 1)', |
||
| 176 | '{var} = ({coords})', |
||
| 177 | [ |
||
| 178 | 'var' => 'x', |
||
| 179 | 'coords' => new ClassString(), |
||
| 180 | ], |
||
| 181 | ], |
||
| 182 | ]; |
||
| 183 | } |
||
| 184 | } |
||
| 185 |