| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| 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 |
||
| 42 | public function providerForUnCachedMethods(): array |
||
| 43 | { |
||
| 44 | $ownerId = 7; |
||
| 45 | $notificationId = 5; |
||
| 46 | $notification = new Notification([ |
||
| 47 | 'id' => $notificationId, |
||
| 48 | 'ownerId' => $ownerId, |
||
| 49 | ]); |
||
| 50 | |||
| 51 | // string $method, array $arguments, array? $tags, string? $key, mixed? $returnValue |
||
| 52 | return [ |
||
| 53 | [ |
||
| 54 | 'createNotification', |
||
| 55 | [ |
||
| 56 | new CreateStruct(['ownerId' => $ownerId]), |
||
| 57 | ], |
||
| 58 | [ |
||
| 59 | 'notification-count-' . $ownerId, |
||
| 60 | 'notification-pending-count-' . $ownerId, |
||
| 61 | ], |
||
| 62 | null, |
||
| 63 | new SPINotification(), |
||
| 64 | ], |
||
| 65 | [ |
||
| 66 | 'updateNotification', |
||
| 67 | [ |
||
| 68 | $notification, |
||
| 69 | new UpdateStruct(['isPending' => false]), |
||
| 70 | ], |
||
| 71 | [ |
||
| 72 | 'notification-' . $notificationId, |
||
| 73 | 'notification-pending-count-' . $ownerId, |
||
| 74 | ], |
||
| 75 | null, |
||
| 76 | new SPINotification(), |
||
| 77 | ], |
||
| 78 | [ |
||
| 79 | 'delete', |
||
| 80 | [ |
||
| 81 | $notification, |
||
| 82 | ], |
||
| 83 | [ |
||
| 84 | 'notification-' . $notificationId, |
||
| 85 | 'notification-count-' . $ownerId, |
||
| 86 | 'notification-pending-count-' . $ownerId, |
||
| 87 | ], |
||
| 88 | ], |
||
| 89 | [ |
||
| 90 | 'loadUserNotifications', [$ownerId, 0, 25], null, null, [], |
||
| 91 | ], |
||
| 92 | ]; |
||
| 93 | } |
||
| 94 | |||
| 134 |