Completed
Pull Request — master (#46)
by
unknown
01:41
created

Stub::getSegmentLeaderboard()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 10
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
namespace Strava\API\Service;
3
4
/**
5
 * Strava stub Service
6
 *
7
 * @author Bas van Dorst
8
 * @package StravaPHP
9
 */
10
class Stub implements ServiceInterface
11
{
12 1
    public function getAthlete($id = null)
13
    {
14 1
        $json = '{ "id": 227615, "resource_state": 2, "firstname": "John", "lastname": "Applestrava", "profile_medium": "http://pics.com/227615/medium.jpg", "profile": "http://pics.com/227615/large.jpg", "city": "San Francisco", "state": "CA", "country": "United States", "sex": "M", "friend": null, "follower": "accepted", "premium": true, "created_at": "2011-03-19T21:59:57Z", "updated_at": "2013-09-05T16:46:54Z", "approve_followers": false }';
15 1
        return $this->format($json);
16
    }
17
18 1
    public function getAthleteStats($id)
19
    {
20 1
        $json = '[ { "biggest_ride_distance": 175454.0, "biggest_climb_elevation_gain": 1882.6999999999998, "recent_ride_totals": { "count": 3, "distance": 12054.900146484375, "moving_time": 2190, "elapsed_time": 2331, "elevation_gain": 36.0, "achievement_count": 0 }, "recent_run_totals": { "count": 23, "distance": 195948.40002441406, "moving_time": 65513, "elapsed_time": 75232, "elevation_gain": 2934.3999996185303, "achievement_count": 46 }, "recent_swim_totals": { "count": 2, "distance": 1117.2000122070312, "moving_time": 1744, "elapsed_time": 1942, "elevation_gain": 0.0, "achievement_count": 0 }, "ytd_ride_totals": { "count": 134, "distance": 4927252, "moving_time": 659982, "elapsed_time": 892644, "elevation_gain": 49940 }, "ytd_run_totals": { "count": 111, "distance": 917100, "moving_time": 272501, "elapsed_time": 328059, "elevation_gain": 7558 }, "ytd_swim_totals": { "count": 8, "distance": 10372, "moving_time": 8784, "elapsed_time": 11123, "elevation_gain": 0 }, "all_ride_totals": { "count": 375, "distance": 15760015, "moving_time": 2155741, "elapsed_time": 2684286, "elevation_gain": 189238 }, "all_run_totals": { "count": 272, "distance": 2269557, "moving_time": 673678, "elapsed_time": 812095, "elevation_gain": 23780 }, "all_swim_totals": { "count": 8, "distance": 10372, "moving_time": 8784, "elapsed_time": 11123, "elevation_gain": 0} } ]';
21 1
        return $this->format($json);
22
    }
23
24 1
    public function getAthleteRoutes($id, $type = null, $after = null, $page = null, $per_page = null)
25
    {
26 1
        $json = '[{"athlete":{"id":19,"resource_state":2},"id":743064,"resource_state":2,"description":"","distance":17781.6,"elevation_gain":207.8}]';
27 1
        return $this->format($json);
28
    }
29
30 1
    public function getAthleteClubs()
31
    {
32 1
        $json = '[ { "id": 1, "resource_state": 2, "name": "Team Strava Cycling", "profile_medium": "http://pics.com/clubs/1/medium.jpg", "profile": "http://pics.com/clubs/1/large.jpg" } ]';
33 1
        return $this->format($json);
34
    }
35
36 1
    public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null)
37
    {
38 1
        $json = '{"response": 1}';
39 1
        return $this->format($json);
40
    }
41
42 1
    public function getAthleteFriends($id = null, $page = null, $per_page = null)
43
    {
44 1
        $json = '{"response": 1}';
45 1
        return $this->format($json);
46
    }
47
48 1
    public function getAthleteFollowers($id = null, $page = null, $per_page = null)
49
    {
50 1
        $json = '{"response": 1}';
51 1
        return $this->format($json);
52
    }
53
54 1
    public function getAthleteBothFollowing($id, $page = null, $per_page = null)
55
    {
56 1
        $json = '{"response": 1}';
57 1
        return $this->format($json);
58
    }
59
60 1
    public function getAthleteKom($id, $page = null, $per_page = null)
61
    {
62 1
        $json = '{"response": 1}';
63 1
        return $this->format($json);
64
    }
65
66 1
    public function getAthleteZones()
67
    {
68 1
        $json = '{"heart_rate":{"custom_zones":false,"zones":[{"min":0,"max":115},{"min":115,"max":152},{"min":152,"max":171},{"min":171,"max":190},{"min":190,"max":-1}]},"power":{"zones":[{"min":0,"max":180},{"min":181,"max":246},{"min":247,"max":295},{"min":296,"max":344},{"min":345,"max":393},{"min":394,"max":492},{"min":493,"max":-1}]}}';
69 1
        return $this->format($json);
70
    }
71
72 1
    public function getAthleteStarredSegments($id = null, $page = null, $per_page = null)
73
    {
74 1
        $json = '{"response": 1}';
75 1
        return $this->format($json);
76
    }
77
78 1
    public function updateAthlete($city, $state, $country, $sex, $weight)
79
    {
80 1
        $json = '{"response": 1}';
81 1
        return $this->format($json);
82
    }
83
84
    public function getActivityFollowing($before = null, $page = null, $per_page = null)
85
    {
86
        $json = '{"response": 1}';
87
        return $this->format($json);
88
    }
89
90 1
    public function getActivity($id, $include_all_efforts = null)
91
    {
92 1
        $json = '{"response": 1}';
93 1
        return $this->format($json);
94
    }
95
96 1
    public function getActivityComments($id, $markdown = null, $page = null, $per_page = null)
97
    {
98 1
        $json = '{"response": 1}';
99 1
        return $this->format($json);
100
    }
101
102 1
    public function getActivityKudos($id, $page = null, $per_page = null)
103
    {
104 1
        $json = '{"response": 1}';
105 1
        return $this->format($json);
106
    }
107
108 1
    public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true')
109
    {
110 1
        $json = '{"response": 1}';
111 1
        return $this->format($json);
112
    }
113
114 1
    public function getActivityZones($id)
115
    {
116 1
        $json = '{"response": 1}';
117 1
        return $this->format($json);
118
    }
119
120 1
    public function getActivityLaps($id)
121
    {
122 1
        $json = '{"response": 1}';
123 1
        return $this->format($json);
124
    }
125
126 1
    public function getActivityUploadStatus($id)
127
    {
128 1
        $json = '{"response": 1}';
129 1
        return $this->format($json);
130
    }
131
132 1
    public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null)
133
    {
134 1
        $json = '{"response": 1}';
135 1
        return $this->format($json);
136
    }
137
138 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
        $json = '{"response": 1}';
141 1
        return $this->format($json);
142
    }
143
144 1
    public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null)
145
    {
146 1
        $json = '{"response": 1}';
147 1
        return $this->format($json);
148
    }
149
150 1
    public function deleteActivity($id)
151
    {
152 1
        $json = '{"response": 1}';
153 1
        return $this->format($json);
154
    }
155
156 1
    public function getGear($id)
157
    {
158 1
        $json = '{"response": 1}';
159 1
        return $this->format($json);
160
    }
161
162 1
    public function getClub($id)
163
    {
164 1
        $json = '{"response": 1}';
165 1
        return $this->format($json);
166
    }
167
168 1
    public function getClubMembers($id, $page = null, $per_page = null)
169
    {
170 1
        $json = '{"response": 1}';
171 1
        return $this->format($json);
172
    }
173
174 1
    public function getClubActivities($id, $page = null, $per_page = null)
175
    {
176 1
        $json = '{"response": 1}';
177 1
        return $this->format($json);
178
    }
179
180 1
    public function getClubAnnouncements($id)
181
    {
182 1
        $json = '{"response": 1}';
183 1
        return $this->format($json);
184
    }
185
186 1
    public function getClubGroupEvents($id)
187
    {
188 1
        $json = '{"response": 1}';
189 1
        return $this->format($json);
190
    }
191
192 1
    public function joinClub($id)
193
    {
194 1
        $json = '{"response": 1}';
195 1
        return $this->format($json);
196
    }
197
198 1
    public function leaveClub($id)
199
    {
200 1
        $json = '{"response": 1}';
201 1
        return $this->format($json);
202
    }
203
204 1
    public function getRoute($id)
205
    {
206 1
        $json = '{"response": 1}';
207 1
        return $this->format($json);
208
    }
209
210 1
    public function getRouteAsGPX($id)
211
    {
212 1
        $gpx = '<?xml version="1.0" encoding="UTF-8"?><gpx creator="StravaGPX"/>';
213 1
        return $gpx;
214
    }
215
216 1
    public function getRouteAsTCX($id)
217
    {
218 1
        $tcx = '<?xml version="1.0" encoding="UTF-8"?><TrainingCenterDatabase/>';
219 1
        return $tcx;
220
    }
221
222 1
    public function getSegment($id)
223
    {
224 1
        $json = '{"response": 1}';
225 1
        return $this->format($json);
226
    }
227
228 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)
229
    {
230 1
        $json = '{"response": 1}';
231 1
        return $this->format($json);
232
    }
233
234 1
    public function getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null)
235
    {
236 1
        $json = '{"response": 1}';
237 1
        return $this->format($json);
238
    }
239
240 1
    public function getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null)
241
    {
242 1
        $json = '{"response": 1}';
243 1
        return $this->format($json);
244
    }
245
246 1
    public function getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance')
247
    {
248 1
        $json = '{"response": 1}';
249 1
        return $this->format($json);
250
    }
251
252 1
    public function getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance')
253
    {
254 1
        $json = '{"response": 1}';
255 1
        return $this->format($json);
256
    }
257
258
    public function getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance')
259
    {
260
        $json = '{"response": 1}';
261 40
        return $this->format($json);
262
    }
263 40
264
    public function getStreamsRoute($id)
265
    {
266
        $json = '{"response": 1}';
267
        return $this->format($json);
268
    }
269
270
    /**
271
     * @param string $result
272
     */
273
    private function format($result)
274
    {
275
        return json_decode($result, true);
276
    }
277
}
278