Conditions | 1 |
Paths | 1 |
Total Lines | 76 |
Code Lines | 79 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
157 | public function resultProvider() |
||
158 | { |
||
159 | yield 'Array iteration' => [ |
||
160 | [ |
||
161 | new Entity([ |
||
162 | 'id' => 1, |
||
163 | 'modified' => new Time('2017-01-01 10:00:00'), |
||
164 | ]), |
||
165 | new Entity([ |
||
166 | 'id' => 3, |
||
167 | 'modified' => new Time('2017-01-01 10:00:00'), |
||
168 | ]), |
||
169 | new Entity([ |
||
170 | 'id' => 5, |
||
171 | 'modified' => new Time('2017-01-01 10:00:00'), |
||
172 | ]), |
||
173 | ], |
||
174 | [ |
||
175 | 'hasPrevious' => null, |
||
176 | 'previousCursor' => null, |
||
177 | 'hasNext' => true, |
||
178 | 'nextCursor' => [ |
||
179 | 'Posts.id' => 2, |
||
180 | 'Posts.modified' => new Time('2017-01-01 11:00:00'), |
||
181 | ], |
||
182 | ], |
||
183 | '{ |
||
184 | "records": [ |
||
185 | { |
||
186 | "id": 1, |
||
187 | "modified": "2017-01-01T10:00:00+00:00" |
||
188 | }, |
||
189 | { |
||
190 | "id": 3, |
||
191 | "modified": "2017-01-01T10:00:00+00:00" |
||
192 | }, |
||
193 | { |
||
194 | "id": 5, |
||
195 | "modified": "2017-01-01T10:00:00+00:00" |
||
196 | } |
||
197 | ], |
||
198 | "hasPrevious": null, |
||
199 | "previousCursor": null, |
||
200 | "hasNext": true, |
||
201 | "nextCursor": { |
||
202 | "Posts.id": 2, |
||
203 | "Posts.modified": "2017-01-01T11:00:00+00:00" |
||
204 | } |
||
205 | }', |
||
206 | ]; |
||
207 | |||
208 | yield 'ArrayIterator iteration' => [ |
||
209 | new ArrayIterator([ |
||
210 | new Entity([ |
||
211 | 'id' => 1, |
||
212 | 'modified' => new Time('2017-01-01 10:00:00'), |
||
213 | ]), |
||
214 | new Entity([ |
||
215 | 'id' => 3, |
||
216 | 'modified' => new Time('2017-01-01 10:00:00'), |
||
217 | ]), |
||
218 | new Entity([ |
||
219 | 'id' => 5, |
||
220 | 'modified' => new Time('2017-01-01 10:00:00'), |
||
221 | ]), |
||
222 | ]), |
||
223 | [ |
||
224 | 'hasPrevious' => null, |
||
225 | 'previousCursor' => null, |
||
226 | 'hasNext' => true, |
||
227 | 'nextCursor' => [ |
||
228 | 'Posts.id' => 2, |
||
229 | 'Posts.modified' => new Time('2017-01-01 11:00:00'), |
||
230 | ], |
||
231 | ], |
||
232 | '{ |
||
233 | "records": [ |
||
258 |