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  | 
            ||
| 10 | class Stub implements ServiceInterface  | 
            ||
| 11 | { | 
            ||
| 12 | 1 | public function getAthlete($id = null)  | 
            |
| 17 | |||
| 18 | 1 | public function getAthleteStats($id)  | 
            |
| 23 | |||
| 24 | 1 | public function getAthleteRoutes($id, $type = null, $after = null, $page = null, $per_page = null)  | 
            |
| 29 | |||
| 30 | 1 | public function getAthleteClubs()  | 
            |
| 35 | |||
| 36 | 1 | public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null)  | 
            |
| 41 | |||
| 42 | 1 | public function getAthleteFriends($id = null, $page = null, $per_page = null)  | 
            |
| 47 | |||
| 48 | 1 | public function getAthleteFollowers($id = null, $page = null, $per_page = null)  | 
            |
| 53 | |||
| 54 | 1 | public function getAthleteBothFollowing($id, $page = null, $per_page = null)  | 
            |
| 59 | |||
| 60 | 1 | public function getAthleteKom($id, $page = null, $per_page = null)  | 
            |
| 65 | |||
| 66 | 1 | public function getAthleteZones()  | 
            |
| 71 | |||
| 72 | 1 | public function getAthleteStarredSegments($id = null, $page = null, $per_page = null)  | 
            |
| 77 | |||
| 78 | 1 | public function updateAthlete($city, $state, $country, $sex, $weight)  | 
            |
| 83 | |||
| 84 | public function getActivityFollowing($before = null, $page = null, $per_page = null)  | 
            ||
| 89 | |||
| 90 | 1 | public function getActivity($id, $include_all_efforts = null)  | 
            |
| 95 | |||
| 96 | 1 | public function getActivityComments($id, $markdown = null, $page = null, $per_page = null)  | 
            |
| 101 | |||
| 102 | 1 | public function getActivityKudos($id, $page = null, $per_page = null)  | 
            |
| 107 | |||
| 108 | 1 | public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true')  | 
            |
| 113 | |||
| 114 | 1 | public function getActivityZones($id)  | 
            |
| 119 | |||
| 120 | 1 | public function getActivityLaps($id)  | 
            |
| 125 | |||
| 126 | 1 | public function getActivityUploadStatus($id)  | 
            |
| 131 | |||
| 132 | 1 | public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null)  | 
            |
| 137 | |||
| 138 | 1 | public function uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $trainer = null, $data_type = null, $external_id = null)  | 
            |
| 143 | |||
| 144 | 1 | public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null)  | 
            |
| 149 | |||
| 150 | 1 | public function deleteActivity($id)  | 
            |
| 155 | |||
| 156 | 1 | public function getGear($id)  | 
            |
| 161 | |||
| 162 | 1 | public function getClub($id)  | 
            |
| 167 | |||
| 168 | 1 | public function getClubMembers($id, $page = null, $per_page = null)  | 
            |
| 173 | |||
| 174 | 1 | public function getClubActivities($id, $page = null, $per_page = null)  | 
            |
| 179 | |||
| 180 | 1 | public function getClubAnnouncements($id)  | 
            |
| 185 | |||
| 186 | 1 | public function getClubGroupEvents($id)  | 
            |
| 191 | |||
| 192 | 1 | public function joinClub($id)  | 
            |
| 197 | |||
| 198 | 1 | public function leaveClub($id)  | 
            |
| 203 | |||
| 204 | 1 | public function getRoute($id)  | 
            |
| 209 | |||
| 210 | 1 | public function getSegment($id)  | 
            |
| 215 | |||
| 216 | 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)  | 
            |
| 221 | |||
| 222 | 1 | public function getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null)  | 
            |
| 227 | |||
| 228 | 1 | public function getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null)  | 
            |
| 233 | |||
| 234 | 1 | public function getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance')  | 
            |
| 239 | |||
| 240 | 1 | public function getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance')  | 
            |
| 245 | |||
| 246 | 1 | public function getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance')  | 
            |
| 251 | |||
| 252 | 1 | public function getStreamsRoute($id)  | 
            |
| 257 | |||
| 258 | /**  | 
            ||
| 259 | * @param string $result  | 
            ||
| 260 | */  | 
            ||
| 261 | 40 | private function format($result)  | 
            |
| 265 | }  | 
            ||
| 266 |