Conditions | 7 |
Paths | 7 |
Total Lines | 51 |
Code Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
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 |
||
68 | private function process() |
||
69 | { |
||
70 | $notifications = $this->requestNotifications(); |
||
71 | if (empty($notifications)) { |
||
72 | return; |
||
73 | } |
||
74 | |||
75 | krsort($notifications); |
||
76 | |||
77 | $wikilog = []; |
||
78 | foreach ($notifications as $notif) { |
||
79 | $title = $notif['title']['full']; |
||
80 | |||
81 | // Skip bot pages |
||
82 | if (in_array( |
||
83 | $title, |
||
84 | self::SKIP_BOTPAGES |
||
85 | ) |
||
86 | ) { |
||
87 | continue; |
||
88 | } |
||
89 | |||
90 | $date = new \DateTime($notif['timestamp']['utciso8601']); |
||
91 | |||
92 | if (isset($notif['title']) && in_array($notif['title']['namespace'], ['', 'Discussion'])) { |
||
93 | $icon = '🌼 '; // Article + Discussion |
||
94 | } |
||
95 | |||
96 | $wikilog[] = sprintf( |
||
97 | '* %s %s[[%s]] ([%s%s diff]) par %s', |
||
98 | $date->format('d-m-Y H\hi'), |
||
99 | $icon ?? '', |
||
100 | $title, |
||
101 | self::DIFF_URL, |
||
102 | $notif['revid'] ?? '', |
||
103 | $notif['agent']['name'] ?? '???' |
||
104 | ); |
||
105 | // dump($notif); |
||
106 | |||
107 | if (!isset($notif['read'])) { |
||
108 | $this->postNotifAsRead($notif['id']); |
||
109 | } |
||
110 | |||
111 | $this->processSpecialActions($notif); |
||
112 | } |
||
113 | |||
114 | dump($wikilog); |
||
115 | |||
116 | echo "sleep 20"; |
||
117 | sleep(20); |
||
118 | $this->editWikilog($wikilog); |
||
119 | } |
||
203 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.