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