| Conditions | 1 |
| Paths | 1 |
| Total Lines | 67 |
| 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 |
||
| 23 | public function serviceProvider() |
||
| 24 | { |
||
| 25 | $notificationId = 5; |
||
| 26 | |||
| 27 | $notification = new Notification([ |
||
| 28 | 'id' => $notificationId, |
||
| 29 | ]); |
||
| 30 | |||
| 31 | $createStruct = new CreateStruct([ |
||
| 32 | 'ownerId' => 10, |
||
| 33 | 'type' => 'Foo', |
||
| 34 | 'data' => [], |
||
| 35 | ]); |
||
| 36 | |||
| 37 | return [ |
||
| 38 | [ |
||
| 39 | 'loadNotifications', |
||
| 40 | [0, 25], |
||
| 41 | new NotificationList(), |
||
| 42 | 0, |
||
| 43 | ], |
||
| 44 | [ |
||
| 45 | 'getNotification', |
||
| 46 | [$notificationId], |
||
| 47 | new Notification(), |
||
| 48 | 0, |
||
| 49 | ], |
||
| 50 | [ |
||
| 51 | 'markNotificationAsRead', |
||
| 52 | [$notification], |
||
| 53 | null, |
||
| 54 | 1, |
||
| 55 | NotificationReadSignal::class, |
||
| 56 | [ |
||
| 57 | 'notificationId' => $notificationId, |
||
| 58 | ], |
||
| 59 | ], |
||
| 60 | [ |
||
| 61 | 'getPendingNotificationCount', |
||
| 62 | [], |
||
| 63 | 10, |
||
| 64 | 0, |
||
| 65 | ], |
||
| 66 | [ |
||
| 67 | 'deleteNotification', |
||
| 68 | [$notification], |
||
| 69 | null, |
||
| 70 | 1, |
||
| 71 | NotificationDeleteSignal::class, |
||
| 72 | [ |
||
| 73 | 'notificationId' => $notificationId, |
||
| 74 | ], |
||
| 75 | ], |
||
| 76 | [ |
||
| 77 | 'createNotification', |
||
| 78 | [$createStruct], |
||
| 79 | $notification, |
||
| 80 | 1, |
||
| 81 | NotificationCreateSignal::class, |
||
| 82 | [ |
||
| 83 | 'ownerId' => $createStruct->ownerId, |
||
| 84 | 'type' => $createStruct->type, |
||
| 85 | 'data' => $createStruct->data, |
||
| 86 | ], |
||
| 87 | ], |
||
| 88 | ]; |
||
| 89 | } |
||
| 90 | |||
| 107 |