Completed
Push — master ( 6a30a3...8c0277 )
by Bas van
02:47
created

Stub::getSegmentLeaderboard()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

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 9.4285
cc 1
eloc 3
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
13
14 1
    public function getAthlete($id = null)
15
    {
16 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 }';
17 1
        return $this->format($json);
18
    }
19
20 1
    public function getAthleteStats($id)
21
    {
22 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} } ]';
23 1
        return $this->format($json);
24
    }
25
26 1
    public function getAthleteClubs()
27
    {
28 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" } ]';
29 1
        return $this->format($json);
30
    }
31
32 1
    public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null)
33
    {
34 1
        $json = '{"response": 1}';
35 1
        return $this->format($json);
36
    }
37
38 1
    public function getAthleteFriends($id = null, $page = null, $per_page = null)
39
    {
40 1
        $json = '{"response": 1}';
41 1
        return $this->format($json);
42
    }
43
44 1
    public function getAthleteFollowers($id = null, $page = null, $per_page = null)
45
    {
46 1
        $json = '{"response": 1}';
47 1
        return $this->format($json);
48
    }
49
50 1
    public function getAthleteBothFollowing($id, $page = null, $per_page = null)
51
    {
52 1
        $json = '{"response": 1}';
53 1
        return $this->format($json);
54
    }
55
56 1
    public function getAthleteKom($id, $page = null, $per_page = null)
57
    {
58 1
        $json = '{"response": 1}';
59 1
        return $this->format($json);
60
    }
61
62 1
    public function getAthleteZones()
63
    {
64 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}]}}';
65 1
        return $this->format($json);
66
    }
67
68 1
    public function getAthleteStarredSegments($id = null, $page = null, $per_page = null)
69
    {
70 1
        $json = '{"response": 1}';
71 1
        return $this->format($json);
72
    }
73
74 1
    public function updateAthlete($city, $state, $country, $sex, $weight)
75
    {
76 1
        $json = '{"response": 1}';
77 1
        return $this->format($json);
78
    }
79
80
    public function getActivityFollowing($before = null, $page = null, $per_page = null)
81
    {
82
        $json = '{"response": 1}';
83
        return $this->format($json);
84
    }
85
86 1
    public function getActivity($id, $include_all_efforts = null)
87
    {
88 1
        $json = '{"response": 1}';
89 1
        return $this->format($json);
90
    }
91
92 1
    public function getActivityComments($id, $markdown = null, $page = null, $per_page = null)
93
    {
94 1
        $json = '{"response": 1}';
95 1
        return $this->format($json);
96
    }
97
98 1
    public function getActivityKudos($id, $page = null, $per_page = null)
99
    {
100 1
        $json = '{"response": 1}';
101 1
        return $this->format($json);
102
    }
103
104 1
    public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true')
105
    {
106 1
        $json = '{"response": 1}';
107 1
        return $this->format($json);
108
    }
109
110 1
    public function getActivityZones($id)
111
    {
112 1
        $json = '{"response": 1}';
113 1
        return $this->format($json);
114
    }
115
116 1
    public function getActivityLaps($id)
117
    {
118 1
        $json = '{"response": 1}';
119 1
        return $this->format($json);
120
    }
121
122 1
    public function getActivityUploadStatus($id)
123
    {
124 1
        $json = '{"response": 1}';
125 1
        return $this->format($json);
126
    }
127
128 1
    public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null)
129
    {
130 1
        $json = '{"response": 1}';
131 1
        return $this->format($json);
132
    }
133
134 1
    public function uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $trainer = null, $data_type = null, $external_id = null)
135
    {
136 1
        $json = '{"response": 1}';
137 1
        return $this->format($json);
138
    }
139
140 1
    public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null)
141
    {
142 1
        $json = '{"response": 1}';
143 1
        return $this->format($json);
144
    }
145
146 1
    public function deleteActivity($id)
147
    {
148 1
        $json = '{"response": 1}';
149 1
        return $this->format($json);
150
    }
151
152 1
    public function getGear($id)
153
    {
154 1
        $json = '{"response": 1}';
155 1
        return $this->format($json);
156
    }
157
158 1
    public function getClub($id)
159
    {
160 1
        $json = '{"response": 1}';
161 1
        return $this->format($json);
162
    }
163
164 1
    public function getClubMembers($id, $page = null, $per_page = null)
165
    {
166 1
        $json = '{"response": 1}';
167 1
        return $this->format($json);
168
    }
169
170 1
    public function getClubActivities($id, $page = null, $per_page = null)
171
    {
172 1
        $json = '{"response": 1}';
173 1
        return $this->format($json);
174
    }
175
176 1
    public function getClubAnnouncements($id)
177
    {
178 1
        $json = '{"response": 1}';
179 1
        return $this->format($json);
180
    }
181
182 1
    public function getClubGroupEvents($id)
183
    {
184 1
        $json = '{"response": 1}';
185 1
        return $this->format($json);
186
    }
187
188 1
    public function joinClub($id)
189
    {
190 1
        $json = '{"response": 1}';
191 1
        return $this->format($json);
192
    }
193
194 1
    public function leaveClub($id)
195
    {
196 1
        $json = '{"response": 1}';
197 1
        return $this->format($json);
198
    }
199
200 1
    public function getSegment($id)
201
    {
202 1
        $json = '{"response": 1}';
203 1
        return $this->format($json);
204
    }
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)
207
    {
208 1
        $json = '{"response": 1}';
209 1
        return $this->format($json);
210
    }
211
212 1
    public function getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null)
213
    {
214 1
        $json = '{"response": 1}';
215 1
        return $this->format($json);
216
    }
217
218 1
    public function getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null)
219
    {
220 1
        $json = '{"response": 1}';
221 1
        return $this->format($json);
222
    }
223
224 1
    public function getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance')
225
    {
226 1
        $json = '{"response": 1}';
227 1
        return $this->format($json);
228
    }
229
230 1
    public function getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance')
231
    {
232 1
        $json = '{"response": 1}';
233 1
        return $this->format($json);
234
    }
235
236 1
    public function getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance')
237
    {
238 1
        $json = '{"response": 1}';
239 1
        return $this->format($json);
240
    }
241
242
    /**
243
     * @param string $result
244
     */
245 37
    private function format($result)
246
    {
247 37
        return json_decode($result, true);
248
    }
249
}
250