Conditions | 1 |
Paths | 1 |
Total Lines | 336 |
Code Lines | 259 |
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 |
||
91 | public function valueServiceProvider() |
||
92 | { |
||
93 | $authorUuid = Uuid::uuid4()->toString(); |
||
94 | $postUuid = Uuid::uuid4()->toString(); |
||
95 | $tagUuid = Uuid::uuid4()->toString(); |
||
96 | $trailUuid = Uuid::uuid4()->toString(); |
||
97 | |||
98 | $author = new Author('Davis', '[email protected]', 'Some string', $authorUuid, new DateTime()); |
||
99 | $post = new Post('A Post', 'Lorem ipsum', $author, $postUuid, [], null); |
||
100 | $tag = new Tag('A tag', $tagUuid); |
||
101 | $trail = new Trail('A trail', 'An amazing trail', $trailUuid, [$post]); |
||
102 | $filters = []; |
||
103 | |||
104 | return [ |
||
105 | [ |
||
106 | CreateAuthor::class, |
||
107 | 'save', |
||
108 | $authorUuid, |
||
109 | $this->getMockForAbstractClass(AbstractAuthorRepository::class), |
||
110 | $author, |
||
111 | $this->createMock(LoggerInterface::class), |
||
112 | $authorUuid, |
||
113 | 'Create author service' |
||
114 | ], |
||
115 | [ |
||
116 | EditAuthor::class, |
||
117 | 'save', |
||
118 | $authorUuid, |
||
119 | $this->getMockForAbstractClass(AbstractAuthorRepository::class), |
||
120 | $author, |
||
121 | $this->createMock(LoggerInterface::class), |
||
122 | $authorUuid, |
||
123 | 'Edit author service' |
||
124 | ], |
||
125 | [ |
||
126 | DeleteAuthor::class, |
||
127 | 'delete', |
||
128 | true, |
||
129 | $this->getMockForAbstractClass(AbstractAuthorRepository::class), |
||
130 | $author, |
||
131 | $this->createMock(LoggerInterface::class), |
||
132 | true, |
||
133 | 'Delete author service' |
||
134 | ], |
||
135 | [ |
||
136 | GetAuthor::class, |
||
137 | 'get', |
||
138 | $author, |
||
139 | $this->getMockForAbstractClass(AbstractAuthorRepository::class), |
||
140 | $authorUuid, |
||
141 | $this->createMock(LoggerInterface::class), |
||
142 | $author, |
||
143 | 'Get author service' |
||
144 | ], |
||
145 | [ |
||
146 | ListAuthors::class, |
||
147 | 'getList', |
||
148 | [$author], |
||
149 | $this->getMockForAbstractClass(AbstractAuthorRepository::class), |
||
150 | $filters, |
||
151 | $this->createMock(LoggerInterface::class), |
||
152 | [$author], |
||
153 | 'List authors service' |
||
154 | ], |
||
155 | [ |
||
156 | CreatePost::class, |
||
157 | 'save', |
||
158 | $postUuid, |
||
159 | $this->getMockForAbstractClass(AbstractPostRepository::class), |
||
160 | $post, |
||
161 | $this->createMock(LoggerInterface::class), |
||
162 | $postUuid, |
||
163 | 'Create post service' |
||
164 | ], |
||
165 | [ |
||
166 | EditPost::class, |
||
167 | 'save', |
||
168 | $postUuid, |
||
169 | $this->getMockForAbstractClass(AbstractPostRepository::class), |
||
170 | $post, |
||
171 | $this->createMock(LoggerInterface::class), |
||
172 | $postUuid, |
||
173 | 'Edit post service' |
||
174 | ], |
||
175 | [ |
||
176 | DeletePost::class, |
||
177 | 'delete', |
||
178 | true, |
||
179 | $this->getMockForAbstractClass(AbstractPostRepository::class), |
||
180 | $post, |
||
181 | $this->createMock(LoggerInterface::class), |
||
182 | true, |
||
183 | 'Delete post service' |
||
184 | ], |
||
185 | [ |
||
186 | GetPost::class, |
||
187 | 'get', |
||
188 | $post, |
||
189 | $this->getMockForAbstractClass(AbstractPostRepository::class), |
||
190 | $postUuid, |
||
191 | $this->createMock(LoggerInterface::class), |
||
192 | $post, |
||
193 | 'Get post service' |
||
194 | ], |
||
195 | [ |
||
196 | ListPosts::class, |
||
197 | 'getList', |
||
198 | [$post], |
||
199 | $this->getMockForAbstractClass(AbstractPostRepository::class), |
||
200 | $filters, |
||
201 | $this->createMock(LoggerInterface::class), |
||
202 | [$post], |
||
203 | 'List posts service' |
||
204 | ], |
||
205 | [ |
||
206 | CreateTag::class, |
||
207 | 'save', |
||
208 | $tagUuid, |
||
209 | $this->getMockForAbstractClass(AbstractTagRepository::class), |
||
210 | $tag, |
||
211 | $this->createMock(LoggerInterface::class), |
||
212 | $tagUuid, |
||
213 | 'Create tag service' |
||
214 | ], |
||
215 | [ |
||
216 | EditTag::class, |
||
217 | 'save', |
||
218 | $tagUuid, |
||
219 | $this->getMockForAbstractClass(AbstractTagRepository::class), |
||
220 | $tag, |
||
221 | $this->createMock(LoggerInterface::class), |
||
222 | $tagUuid, |
||
223 | 'Edit tag service' |
||
224 | ], |
||
225 | [ |
||
226 | DeleteTag::class, |
||
227 | 'delete', |
||
228 | true, |
||
229 | $this->getMockForAbstractClass(AbstractTagRepository::class), |
||
230 | $tag, |
||
231 | $this->createMock(LoggerInterface::class), |
||
232 | true, |
||
233 | 'Delete tag service' |
||
234 | ], |
||
235 | [ |
||
236 | GetTag::class, |
||
237 | 'get', |
||
238 | $tag, |
||
239 | $this->getMockForAbstractClass(AbstractTagRepository::class), |
||
240 | $tagUuid, |
||
241 | $this->createMock(LoggerInterface::class), |
||
242 | $tag, |
||
243 | 'Get tag service' |
||
244 | ], |
||
245 | [ |
||
246 | ListTags::class, |
||
247 | 'getList', |
||
248 | [$tag], |
||
249 | $this->getMockForAbstractClass(AbstractTagRepository::class), |
||
250 | $filters, |
||
251 | $this->createMock(LoggerInterface::class), |
||
252 | [$tag], |
||
253 | 'List tags service' |
||
254 | ], |
||
255 | [ |
||
256 | CreateTrail::class, |
||
257 | 'save', |
||
258 | $trailUuid, |
||
259 | $this->getMockForAbstractClass(AbstractTrailRepository::class), |
||
260 | $trail, |
||
261 | $this->createMock(LoggerInterface::class), |
||
262 | $trailUuid, |
||
263 | 'Create trail service' |
||
264 | ], |
||
265 | [ |
||
266 | EditTrail::class, |
||
267 | 'save', |
||
268 | $trailUuid, |
||
269 | $this->getMockForAbstractClass(AbstractTrailRepository::class), |
||
270 | $trail, |
||
271 | $this->createMock(LoggerInterface::class), |
||
272 | $trailUuid, |
||
273 | 'Edit trail service' |
||
274 | ], |
||
275 | [ |
||
276 | DeleteTrail::class, |
||
277 | 'delete', |
||
278 | true, |
||
279 | $this->getMockForAbstractClass(AbstractTrailRepository::class), |
||
280 | $trail, |
||
281 | $this->createMock(LoggerInterface::class), |
||
282 | true, |
||
283 | 'Delete trail service' |
||
284 | ], |
||
285 | [ |
||
286 | GetTrail::class, |
||
287 | 'get', |
||
288 | $trail, |
||
289 | $this->getMockForAbstractClass(AbstractTrailRepository::class), |
||
290 | $trailUuid, |
||
291 | $this->createMock(LoggerInterface::class), |
||
292 | $trail, |
||
293 | 'Get trail service' |
||
294 | ], |
||
295 | [ |
||
296 | ListTrails::class, |
||
297 | 'getList', |
||
298 | [$trail], |
||
299 | $this->getMockForAbstractClass(AbstractTrailRepository::class), |
||
300 | $filters, |
||
301 | $this->createMock(LoggerInterface::class), |
||
302 | [$trail], |
||
303 | 'List trails service' |
||
304 | ], |
||
305 | [ |
||
306 | DeleteAuthor::class, |
||
307 | 'delete', |
||
308 | false, |
||
309 | $this->getMockForAbstractClass(AbstractAuthorRepository::class), |
||
310 | $author, |
||
311 | $this->createMock(LoggerInterface::class), |
||
312 | false, |
||
313 | 'Delete author service' |
||
314 | ], |
||
315 | [ |
||
316 | GetAuthor::class, |
||
317 | 'get', |
||
318 | null, |
||
319 | $this->getMockForAbstractClass(AbstractAuthorRepository::class), |
||
320 | $authorUuid, |
||
321 | $this->createMock(LoggerInterface::class), |
||
322 | null, |
||
323 | 'Get author service' |
||
324 | ], |
||
325 | [ |
||
326 | ListAuthors::class, |
||
327 | 'getList', |
||
328 | [], |
||
329 | $this->getMockForAbstractClass(AbstractAuthorRepository::class), |
||
330 | $filters, |
||
331 | $this->createMock(LoggerInterface::class), |
||
332 | [], |
||
333 | 'List authors service' |
||
334 | ], |
||
335 | [ |
||
336 | DeletePost::class, |
||
337 | 'delete', |
||
338 | false, |
||
339 | $this->getMockForAbstractClass(AbstractPostRepository::class), |
||
340 | $post, |
||
341 | $this->createMock(LoggerInterface::class), |
||
342 | false, |
||
343 | 'Delete post service' |
||
344 | ], |
||
345 | [ |
||
346 | GetPost::class, |
||
347 | 'get', |
||
348 | null, |
||
349 | $this->getMockForAbstractClass(AbstractPostRepository::class), |
||
350 | $postUuid, |
||
351 | $this->createMock(LoggerInterface::class), |
||
352 | null, |
||
353 | 'Get post service' |
||
354 | ], |
||
355 | [ |
||
356 | ListPosts::class, |
||
357 | 'getList', |
||
358 | [], |
||
359 | $this->getMockForAbstractClass(AbstractPostRepository::class), |
||
360 | $filters, |
||
361 | $this->createMock(LoggerInterface::class), |
||
362 | [], |
||
363 | 'List posts service' |
||
364 | ], |
||
365 | [ |
||
366 | DeleteTag::class, |
||
367 | 'delete', |
||
368 | false, |
||
369 | $this->getMockForAbstractClass(AbstractTagRepository::class), |
||
370 | $tag, |
||
371 | $this->createMock(LoggerInterface::class), |
||
372 | false, |
||
373 | 'Delete tag service' |
||
374 | ], |
||
375 | [ |
||
376 | GetTag::class, |
||
377 | 'get', |
||
378 | null, |
||
379 | $this->getMockForAbstractClass(AbstractTagRepository::class), |
||
380 | $tagUuid, |
||
381 | $this->createMock(LoggerInterface::class), |
||
382 | null, |
||
383 | 'Get tag service' |
||
384 | ], |
||
385 | [ |
||
386 | ListTags::class, |
||
387 | 'getList', |
||
388 | [], |
||
389 | $this->getMockForAbstractClass(AbstractTagRepository::class), |
||
390 | $filters, |
||
391 | $this->createMock(LoggerInterface::class), |
||
392 | [], |
||
393 | 'List tags service' |
||
394 | ], |
||
395 | [ |
||
396 | DeleteTrail::class, |
||
397 | 'delete', |
||
398 | false, |
||
399 | $this->getMockForAbstractClass(AbstractTrailRepository::class), |
||
400 | $trail, |
||
401 | $this->createMock(LoggerInterface::class), |
||
402 | false, |
||
403 | 'Delete trail service' |
||
404 | ], |
||
405 | [ |
||
406 | GetTrail::class, |
||
407 | 'get', |
||
408 | null, |
||
409 | $this->getMockForAbstractClass(AbstractTrailRepository::class), |
||
410 | $trailUuid, |
||
411 | $this->createMock(LoggerInterface::class), |
||
412 | null, |
||
413 | 'Get trail service' |
||
414 | ], |
||
415 | [ |
||
416 | ListTrails::class, |
||
417 | 'getList', |
||
418 | [], |
||
419 | $this->getMockForAbstractClass(AbstractTrailRepository::class), |
||
420 | $filters, |
||
421 | $this->createMock(LoggerInterface::class), |
||
422 | [], |
||
423 | 'List trails service' |
||
424 | ] |
||
425 | ]; |
||
426 | } |
||
427 | |||
625 |