Complex classes like Stub often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Stub, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
11 | class Stub implements ServiceInterface |
||
12 | { |
||
13 | 1 | public function getAthlete($id = null) |
|
18 | |||
19 | 1 | public function getAthleteStats($id) |
|
24 | |||
25 | 1 | public function getAthleteRoutes($id, $type = null, $after = null, $page = null, $per_page = null) |
|
30 | |||
31 | 1 | public function getAthleteClubs() |
|
36 | |||
37 | 1 | public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null) |
|
42 | |||
43 | 1 | public function getAthleteFriends($id = null, $page = null, $per_page = null) |
|
48 | |||
49 | 1 | public function getAthleteFollowers($id = null, $page = null, $per_page = null) |
|
54 | |||
55 | 1 | public function getAthleteBothFollowing($id, $page = null, $per_page = null) |
|
60 | |||
61 | 1 | public function getAthleteKom($id, $page = null, $per_page = null) |
|
66 | |||
67 | 1 | public function getAthleteZones() |
|
72 | |||
73 | 1 | public function getAthleteStarredSegments($id = null, $page = null, $per_page = null) |
|
78 | |||
79 | 1 | public function updateAthlete($city, $state, $country, $sex, $weight) |
|
84 | |||
85 | public function getActivityFollowing($before = null, $page = null, $per_page = null) |
||
90 | |||
91 | 1 | public function getActivity($id, $include_all_efforts = null) |
|
96 | |||
97 | 1 | public function getActivityComments($id, $markdown = null, $page = null, $per_page = null) |
|
102 | |||
103 | 1 | public function getActivityKudos($id, $page = null, $per_page = null) |
|
108 | |||
109 | 1 | public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true') |
|
114 | |||
115 | 1 | public function getActivityZones($id) |
|
120 | |||
121 | 1 | public function getActivityLaps($id) |
|
126 | |||
127 | 1 | public function getActivityUploadStatus($id) |
|
132 | |||
133 | 1 | public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null, $private = null, $trainer = null) |
|
138 | |||
139 | 1 | public function uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $trainer = null, $commute = null, $data_type = null, $external_id = null) |
|
144 | |||
145 | 1 | public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null) |
|
150 | |||
151 | 1 | public function deleteActivity($id) |
|
156 | |||
157 | 1 | public function getGear($id) |
|
162 | |||
163 | 1 | public function getClub($id) |
|
168 | |||
169 | 1 | public function getClubMembers($id, $page = null, $per_page = null) |
|
174 | |||
175 | 1 | public function getClubActivities($id, $page = null, $per_page = null) |
|
180 | |||
181 | 1 | public function getClubAnnouncements($id) |
|
186 | |||
187 | 1 | public function getClubGroupEvents($id) |
|
192 | |||
193 | 1 | public function joinClub($id) |
|
198 | |||
199 | 1 | public function leaveClub($id) |
|
204 | |||
205 | 1 | public function getRoute($id) |
|
210 | |||
211 | 1 | public function getRouteAsGPX($id) |
|
216 | |||
217 | 1 | public function getRouteAsTCX($id) |
|
222 | |||
223 | 1 | public function getSegment($id) |
|
228 | |||
229 | 1 | public function getSegmentLeaderboard($id, $gender = null, $age_group = null, $weight_class = null, $following = null, $club_id = null, $date_range = null, $context_entries = null, $page = null, $per_page = null) |
|
234 | |||
235 | 1 | public function getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null) |
|
240 | |||
241 | 1 | public function getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null) |
|
246 | |||
247 | 1 | public function getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance') |
|
252 | |||
253 | 1 | public function getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance') |
|
258 | |||
259 | 1 | public function getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance') |
|
264 | |||
265 | 1 | public function getStreamsRoute($id) |
|
270 | |||
271 | /** |
||
272 | * @param string $result |
||
273 | * @return mixed |
||
274 | */ |
||
275 | 40 | private function format($result) |
|
279 | } |
||
280 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.