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 | |||
| 13 | |||
| 14 | 1 | public function getAthlete($id = null)  | 
            |
| 19 | |||
| 20 | 1 | public function getAthleteStats($id)  | 
            |
| 25 | |||
| 26 | 1 | public function getAthleteClubs()  | 
            |
| 31 | |||
| 32 | 1 | public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null)  | 
            |
| 37 | |||
| 38 | 1 | public function getAthleteFriends($id = null, $page = null, $per_page = null)  | 
            |
| 43 | |||
| 44 | 1 | public function getAthleteFollowers($id = null, $page = null, $per_page = null)  | 
            |
| 49 | |||
| 50 | 1 | public function getAthleteBothFollowing($id, $page = null, $per_page = null)  | 
            |
| 55 | |||
| 56 | 1 | public function getAthleteKom($id, $page = null, $per_page = null)  | 
            |
| 61 | |||
| 62 | 1 | public function getAthleteZones()  | 
            |
| 67 | |||
| 68 | 1 | public function getAthleteStarredSegments($id = null, $page = null, $per_page = null)  | 
            |
| 73 | |||
| 74 | 1 | public function updateAthlete($city, $state, $country, $sex, $weight)  | 
            |
| 79 | |||
| 80 | public function getActivityFollowing($before = null, $page = null, $per_page = null)  | 
            ||
| 85 | |||
| 86 | 1 | public function getActivity($id, $include_all_efforts = null)  | 
            |
| 91 | |||
| 92 | 1 | public function getActivityComments($id, $markdown = null, $page = null, $per_page = null)  | 
            |
| 97 | |||
| 98 | 1 | public function getActivityKudos($id, $page = null, $per_page = null)  | 
            |
| 103 | |||
| 104 | 1 | public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true')  | 
            |
| 109 | |||
| 110 | 1 | public function getActivityZones($id)  | 
            |
| 115 | |||
| 116 | 1 | public function getActivityLaps($id)  | 
            |
| 121 | |||
| 122 | 1 | public function getActivityUploadStatus($id)  | 
            |
| 127 | |||
| 128 | 1 | public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null)  | 
            |
| 133 | |||
| 134 | 1 | public function uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $trainer = null, $data_type = null, $external_id = null)  | 
            |
| 139 | |||
| 140 | 1 | public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null)  | 
            |
| 145 | |||
| 146 | 1 | public function deleteActivity($id)  | 
            |
| 151 | |||
| 152 | 1 | public function getGear($id)  | 
            |
| 157 | |||
| 158 | 1 | public function getClub($id)  | 
            |
| 163 | |||
| 164 | 1 | public function getClubMembers($id, $page = null, $per_page = null)  | 
            |
| 169 | |||
| 170 | 1 | public function getClubActivities($id, $page = null, $per_page = null)  | 
            |
| 175 | |||
| 176 | 1 | public function getClubAnnouncements($id)  | 
            |
| 181 | |||
| 182 | 1 | public function getClubGroupEvents($id)  | 
            |
| 187 | |||
| 188 | 1 | public function joinClub($id)  | 
            |
| 193 | |||
| 194 | 1 | public function leaveClub($id)  | 
            |
| 199 | |||
| 200 | 1 | public function getSegment($id)  | 
            |
| 205 | |||
| 206 | 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)  | 
            |
| 211 | |||
| 212 | 1 | public function getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null)  | 
            |
| 217 | |||
| 218 | 1 | public function getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null)  | 
            |
| 223 | |||
| 224 | 1 | public function getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance')  | 
            |
| 229 | |||
| 230 | 1 | public function getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance')  | 
            |
| 235 | |||
| 236 | 1 | public function getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance')  | 
            |
| 241 | |||
| 242 | 1 | public function getStreamsRoute($id)  | 
            |
| 247 | |||
| 248 | /**  | 
            ||
| 249 | * @param string $result  | 
            ||
| 250 | */  | 
            ||
| 251 | 38 | private function format($result)  | 
            |
| 255 | }  | 
            ||
| 256 |