Completed
Pull Request — master (#38)
by
unknown
07:39
created

Client   D

Complexity

Total Complexity 85

Size/Duplication

Total Lines 818
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 92.98%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 85
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 818
ccs 159
cts 171
cp 0.9298
rs 4.4444

43 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAthlete() 0 8 2
A getAthleteStats() 0 8 2
A getAthleteClubs() 0 8 2
A getAthleteActivities() 0 8 2
A getAthleteFriends() 0 8 2
A getAthleteFollowers() 0 8 2
A getAthleteBothFollowing() 0 8 2
A getAthleteKom() 0 8 2
A getAthleteZones() 0 8 2
A getAthleteStarredSegments() 0 8 2
A updateAthlete() 0 8 2
A getActivityFollowing() 0 8 2
A getActivity() 0 8 2
A getActivityComments() 0 8 2
A getActivityKudos() 0 8 2
A getActivityPhotos() 0 8 2
A getActivityZones() 0 8 2
A getActivityLaps() 0 8 2
A getActivityUploadStatus() 0 8 2
A createActivity() 0 8 2
A uploadActivity() 0 8 2
A updateActivity() 0 8 2
A deleteActivity() 0 8 2
A getGear() 0 8 2
A getClub() 0 8 2
A getClubMembers() 0 8 2
A getClubActivities() 0 8 2
A getClubAnnouncements() 0 8 2
A getClubGroupEvents() 0 8 2
A joinClub() 0 8 2
A leaveClub() 0 8 2
A getAthleteRoutes() 0 8 2
A getRoute() 0 8 2
A getRoutes() 0 8 2
A getSegment() 0 8 2
A getSegmentLeaderboard() 0 8 2
A getSegmentExplorer() 0 8 2
A getSegmentEffort() 0 8 2
A getStreamsActivity() 0 8 2
A getStreamsEffort() 0 8 2
A getStreamsSegment() 0 8 2
A getStreamsRoute() 0 8 2

How to fix   Complexity   

Complex Class

Complex classes like Client 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 Client, and based on these observations, apply Extract Interface, too.

1
<?php
2
namespace Strava\API;
3
4
use Strava\API\Service\ServiceInterface;
5
use Strava\API\Exception as ClientException;
6
use Strava\API\Service\Exception as ServiceException;
7
8
/**
9
 * Strava API Client
10
 *
11
 * @author Bas van Dorst
12
 * @package StravaPHP
13
 */
14
class Client
15
{
16
    /**
17
     * @var ServiceInterface $service
18
     */
19
    protected $service;
20
21
    /**
22
     * Initiate this class with a subclass of ServiceInterface. There are two
23
     * service subclasses available:
24
     * - Service\REST: Service which makes calls to the live Strava API
25
     * - Service\Stub: Service stub for test purposes (unit tests)
26
     *
27
     * @param ServiceInterface $service
28
     */
29 79
    public function __construct(ServiceInterface $service)
30
    {
31 79
        $this->service = $service;
32 79
    }
33
34
    /**
35
     * Retrieve current athlete
36
     *
37
     * @link    https://strava.github.io/api/v3/athlete/#get-details,
38
     *          https://strava.github.io/api/v3/athlete/#get-another-details
39
     * @param   int $id
40
     * @return  array
41
     * @throws  Exception
42
     */
43 2
    public function getAthlete($id = null)
44
    {
45
        try {
46 2
            return $this->service->getAthlete($id);
47 1
        } catch (ServiceException $e) {
48 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
49
        }
50
    }
51
52
    /**
53
     * Retrieve athlete stats
54
     *
55
     * Only available for the authenticated athlete.
56
     *
57
     * @link    https://strava.github.io/api/v3/athlete/#stats
58
     * @param   int $id
59
     * @return  array
60
     * @throws  ClientException
61
     */
62 1
    public function getAthleteStats($id)
63
    {
64
        try {
65 1
            return $this->service->getAthleteStats($id);
66
        } catch (ServiceException $e) {
67
            throw new ClientException('[SERVICE] ' . $e->getMessage());
68
        }
69
    }
70
71
    /**
72
     * Retrieve athlete routes
73
     *
74
     * @link    https://strava.github.io/api/v3/routes/#list
75
     * @param   int $id
76
     * @return  array
77
     * @throws  ClientException
78
     */
79 1
    public function getAthleteRoutes($id, $type = null, $after = null, $page = null, $per_page = null)
80
    {
81
        try {
82 1
            return $this->service->getAthleteRoutes($id, $type, $after, $page, $per_page);
83
        } catch (ServiceException $e) {
84
            throw new ClientException('[SERVICE] ' . $e->getMessage());
85
        }
86
    }
87
88
    /**
89
     * List athlete clubs
90
     *
91
     * @link    https://strava.github.io/api/v3/clubs/#get-athletes
92
     * @return  array
93
     * @throws  Exception
94
     */
95 2
    public function getAthleteClubs()
96
    {
97
        try {
98 2
            return $this->service->getAthleteClubs();
99 1
        } catch (ServiceException $e) {
100 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
101
        }
102
    }
103
104
    /**
105
     * List athlete activities
106
     *
107
     * @link    https://strava.github.io/api/v3/activities/#get-activities
108
     * @param   string $before
109
     * @param   string $after
110
     * @param   int $page
111
     * @param   int $per_page
112
     * @return  array
113
     * @throws  Exception
114
     */
115 2
    public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null)
116
    {
117
        try {
118 2
            return $this->service->getAthleteActivities($before, $after, $page, $per_page);
119 1
        } catch (ServiceException $e) {
120 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
121
        }
122
    }
123
124
    /**
125
     * List athlete friends
126
     *
127
     * @link    https://strava.github.io/api/v3/follow/#friends
128
     * @param   int $id
129
     * @param   int $page
130
     * @param   int $per_page
131
     * @return  array
132
     * @throws  Exception
133
     */
134 2
    public function getAthleteFriends($id = null, $page = null, $per_page = null)
135
    {
136
        try {
137 2
            return $this->service->getAthleteFriends($id, $page, $per_page);
138 1
        } catch (ServiceException $e) {
139 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
140
        }
141
    }
142
143
    /**
144
     * List athlete followers
145
     *
146
     * @link    https://strava.github.io/api/v3/follow/#followers
147
     * @param   int $id
148
     * @param   int $page
149
     * @param   int $per_page
150
     * @return  array
151
     * @throws  Exception
152
     */
153 2
    public function getAthleteFollowers($id = null, $page = null, $per_page = null)
154
    {
155
        try {
156 2
            return $this->service->getAthleteFollowers($id, $page, $per_page);
157 1
        } catch (ServiceException $e) {
158 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
159
        }
160
    }
161
162
    /**
163
     * List both following
164
     *
165
     * @link    https://strava.github.io/api/v3/follow/#both
166
     * @param   int $id
167
     * @param   int $page
168
     * @param   int $per_page
169
     * @return  array
170
     * @throws  Exception
171
     */
172 2
    public function getAthleteBothFollowing($id, $page = null, $per_page = null)
173
    {
174
        try {
175 2
            return $this->service->getAthleteBothFollowing($id, $page, $per_page);
176 1
        } catch (ServiceException $e) {
177 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
178
        }
179
    }
180
181
    /**
182
     * List athlete K/QOMs/CRs
183
     *
184
     * @link    https://strava.github.io/api/v3/athlete/#koms
185
     * @param   int $id
186
     * @param   int $page
187
     * @param   int $per_page
188
     * @return  array
189
     * @throws  Exception
190
     */
191 2
    public function getAthleteKom($id, $page = null, $per_page = null)
192
    {
193
        try {
194 2
            return $this->service->getAthleteKom($id, $page, $per_page);
195 1
        } catch (ServiceException $e) {
196 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
197
        }
198
    }
199
200
    /**
201
     * List athlete zones
202
     *
203
     * @link    https://strava.github.io/api/v3/athlete/#zones
204
     * @return  array
205
     * @throws  Exception
206
     */
207 2
    public function getAthleteZones()
208
    {
209
        try {
210 2
            return $this->service->getAthleteZones();
211 1
        } catch (ServiceException $e) {
212 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
213
        }
214
    }
215
216
217
218
    /**
219
     * List starred segment
220
     *
221
     * @link    https://strava.github.io/api/v3/segments/#starred
222
     * @param   int $id
223
     * @param   int $page
224
     * @param   int $per_page
225
     * @return  array
226
     * @throws  Exception
227
     */
228 2
    public function getAthleteStarredSegments($id = null, $page = null, $per_page = null)
229
    {
230
        try {
231 2
            return $this->service->getAthleteStarredSegments($id, $page, $per_page);
232 1
        } catch (ServiceException $e) {
233 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
234
        }
235
    }
236
237
    /**
238
     * Update current athlete
239
     *
240
     * @link    https://strava.github.io/api/v3/athlete/#update
241
     * @param   string $city
242
     * @param   string $state
243
     * @param   string $country
244
     * @param   string $sex
245
     * @param   float $weight
246
     * @return  array
247
     * @throws  Exception
248
     */
249 2
    public function updateAthlete($city, $state, $country, $sex, $weight)
250
    {
251
        try {
252 2
            return $this->service->updateAthlete($city, $state, $country, $sex, $weight);
253 1
        } catch (ServiceException $e) {
254 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
255
        }
256
    }
257
258
    /**
259
     * Retrieve activity from user followers
260
     *
261
     * @link https://strava.github.io/api/v3/activities/#get-feed
262
     *
263
     * @param type $before
264
     * @param type $page
265
     * @param type $per_page
266
     * @return type
267
     * @throws ClientException
268
     */
269
    public function getActivityFollowing($before = null, $page = null, $per_page = null)
270
    {
271
        try {
272
            return $this->service->getActivityFollowing($before, $page, $per_page);
273
        } catch (ServiceException $e) {
274
            throw new ClientException('[SERVICE] ' . $e->getMessage());
275
        }
276
    }
277
278
279
    /**
280
     * Retrieve an activity
281
     *
282
     * @link    https://strava.github.io/api/v3/athlete/#get-details,
283
     *          https://strava.github.io/api/v3/athlete/#get-another-details
284
     * @param   int $id
285
     * @param   boolean $include_all_efforts
286
     * @return  array
287
     * @throws  Exception
288
     */
289 2
    public function getActivity($id, $include_all_efforts = null)
290
    {
291
        try {
292 2
            return $this->service->getActivity($id, $include_all_efforts);
293 1
        } catch (ServiceException $e) {
294 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
295
        }
296
    }
297
298
    /**
299
     * List activity comments
300
     *
301
     * @link    https://strava.github.io/api/v3/comments/#list
302
     * @param   int $id
303
     * @param   boolean $markdown
304
     * @param   int $page
305
     * @param   int $per_page
306
     * @return  array
307
     * @throws  Exception
308
     */
309 2
    public function getActivityComments($id, $markdown = null, $page = null, $per_page = null)
310
    {
311
        try {
312 2
            return $this->service->getActivityComments($id, $markdown, $page, $per_page);
313 1
        } catch (ServiceException $e) {
314 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
315
        }
316
    }
317
318
    /**
319
     * List activity kudoers
320
     *
321
     * @link    https://strava.github.io/api/v3/kudos/#list
322
     * @param   int $id
323
     * @param   int $page
324
     * @param   int $per_page
325
     * @return  array
326
     * @throws  Exception
327
     */
328 2
    public function getActivityKudos($id, $page = null, $per_page = null)
329
    {
330
        try {
331 2
            return $this->service->getActivityKudos($id, $page, $per_page);
332 1
        } catch (ServiceException $e) {
333 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
334
        }
335
    }
336
337
    /**
338
     * List activity photos
339
     *
340
     * @link    https://strava.github.io/api/v3/photos/#list
341
     * @param   int $id
342
     * @param   int $size In pixels.
343
     * @param   string $photo_sources Must be "true".
344
     * @return  array
345
     * @throws  Exception
346
     */
347 2
    public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true')
348
    {
349
        try {
350 2
            return $this->service->getActivityPhotos($id, $size, $photo_sources);
351 1
        } catch (ServiceException $e) {
352 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
353
        }
354
    }
355
356
    /**
357
     * List activity zones
358
     *
359
     * @link    https://strava.github.io/api/v3/activities/#zones
360
     * @param   int $id
361
     * @return  array
362
     * @throws  Exception
363
     */
364 2
    public function getActivityZones($id)
365
    {
366
        try {
367 2
            return $this->service->getActivityZones($id);
368 1
        } catch (ServiceException $e) {
369 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
370
        }
371
    }
372
373
    /**
374
     * List activity laps
375
     *
376
     * @link    https://strava.github.io/api/v3/activities/#laps
377
     * @param   int $id
378
     * @return  array
379
     * @throws  Exception
380
     */
381 2
    public function getActivityLaps($id)
382
    {
383
        try {
384 2
            return $this->service->getActivityLaps($id);
385 1
        } catch (ServiceException $e) {
386 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
387
        }
388
    }
389
390
    /**
391
     * Check upload status
392
     *
393
     * @link    https://strava.github.io/api/v3/uploads/#get-status
394
     * @param   int $id
395
     * @return  array
396
     * @throws  Exception
397
     */
398 2
    public function getActivityUploadStatus($id)
399
    {
400
        try {
401 2
            return $this->service->getActivityUploadStatus($id);
402 1
        } catch (ServiceException $e) {
403 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
404
        }
405
    }
406
407
    /**
408
     * Create an activity
409
     *
410
     * @link    https://strava.github.io/api/v3/activities/#create
411
     * @param   string $name
412
     * @param   string $type
413
     * @param   string $start_date_local
414
     * @param   int $elapsed_time
415
     * @param   string $description
416
     * @param   float $distance
417
     * @param   int $private
418
     * @param   int $trainer
419
     * @return  array
420
     * @throws  Exception
421
     */
422 2
    public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null, $private = null, $trainer = null)
423
    {
424
        try {
425 2
            return $this->service->createActivity($name, $type, $start_date_local, $elapsed_time, $description, $distance, $private, $trainer);
0 ignored issues
show
Unused Code introduced by
The call to ServiceInterface::createActivity() has too many arguments starting with $private.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
426 1
        } catch (ServiceException $e) {
427 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
428
        }
429
    }
430
431
    /**
432
     * Upload an activity
433
     *
434
     * @link    https://strava.github.io/api/v3/uploads/#post-file
435
     * @param   mixed $file
436
     * @param   string $activity_type
437
     * @param   string $name
438
     * @param   string $description
439
     * @param   int $private
440
     * @param   int $trainer
441
     * @param   int $commute
442
     * @param   string $data_type
443
     * @param   string $external_id
444
     * @return  array
445
     * @throws  Exception
446
     */
447 2
    public function uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $trainer = null, $commute = null, $data_type = null, $external_id = null)
448
    {
449
        try {
450 2
            return $this->service->uploadActivity($file, $activity_type, $name, $description, $private, $trainer, $commute, $data_type, $external_id);
0 ignored issues
show
Unused Code introduced by
The call to ServiceInterface::uploadActivity() has too many arguments starting with $external_id.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
451 1
        } catch (ServiceException $e) {
452 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
453
        }
454
    }
455
456
    /**
457
     * Update an activity
458
     *
459
     * @link    https://strava.github.io/api/v3/activities/#put-updates
460
     * @param   int $id
461
     * @param   string $name
462
     * @param   string $type
463
     * @param   boolean $private
464
     * @param   boolean $commute
465
     * @param   boolean $trainer
466
     * @param   string $gear_id
467
     * @param   string $description
468
     * @return  array
469
     * @throws  Exception
470
     */
471 2
    public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null)
472
    {
473
        try {
474 2
            return $this->service->updateActivity($id, $name, $type, $private, $commute, $trainer, $gear_id, $description);
475 1
        } catch (ServiceException $e) {
476 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
477
        }
478
    }
479
480
    /**
481
     * Delete an activity
482
     *
483
     * @link    https://strava.github.io/api/v3/activities/#delete
484
     * @param   int $id
485
     * @return  array
486
     * @throws  Exception
487
     */
488 2
    public function deleteActivity($id)
489
    {
490
        try {
491 2
            return $this->service->deleteActivity($id);
492 1
        } catch (ServiceException $e) {
493 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
494
        }
495
    }
496
497
    /**
498
     * Retrieve gear
499
     *
500
     * @link    https://strava.github.io/api/v3/gear/
501
     * @param   int $id
502
     * @return  array
503
     * @throws  Exception
504
     */
505 2
    public function getGear($id)
506
    {
507
        try {
508 2
            return $this->service->getGear($id);
509 1
        } catch (ServiceException $e) {
510 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
511
        }
512
    }
513
514
    /**
515
     * Retrieve a club
516
     *
517
     * @link    https://strava.github.io/api/v3/clubs/#get-details
518
     * @param   int $id
519
     * @return  array
520
     * @throws  Exception
521
     */
522 2
    public function getClub($id)
523
    {
524
        try {
525 2
            return $this->service->getClub($id);
526 1
        } catch (ServiceException $e) {
527 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
528
        }
529
    }
530
531
    /**
532
     * List club members
533
     *
534
     * @link    https://strava.github.io/api/v3/clubs/#get-members
535
     * @param   int $id
536
     * @param   int $page
537
     * @param   int $per_page
538
     * @return  array
539
     * @throws  Exception
540
     */
541 2
    public function getClubMembers($id, $page = null, $per_page = null)
542
    {
543
        try {
544 2
            return $this->service->getClubMembers($id, $page, $per_page);
545 1
        } catch (ServiceException $e) {
546 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
547
        }
548
    }
549
550
    /**
551
     * List club activities
552
     *
553
     * @link    https://strava.github.io/api/v3/clubs/#get-activities
554
     * @param   int $id
555
     * @param   int $page
556
     * @param   int $per_page
557
     * @return  array
558
     * @throws  Exception
559
     */
560 2
    public function getClubActivities($id, $page = null, $per_page = null)
561
    {
562
        try {
563 2
            return $this->service->getClubActivities($id, $page, $per_page);
564 1
        } catch (ServiceException $e) {
565 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
566
        }
567
    }
568
569
    /**
570
     * List club announcements
571
     *
572
     * @link    https://strava.github.io/api/v3/clubs/#get-announcements
573
     * @param   int $id
574
     * @return  array
575
     * @throws  Exception
576
     */
577 2
    public function getClubAnnouncements($id)
578
    {
579
        try {
580 2
            return $this->service->getClubAnnouncements($id);
581 1
        } catch (ServiceException $e) {
582 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
583
        }
584
    }
585
586
    /**
587
     * List club group events
588
     *
589
     * @link    https://strava.github.io/api/v3/clubs/#get-group-events
590
     * @param   int $id
591
     * @return  array
592
     * @throws  Exception
593
     */
594 2
    public function getClubGroupEvents($id)
595
    {
596
        try {
597 2
            return $this->service->getClubGroupEvents($id);
598 1
        } catch (ServiceException $e) {
599 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
600
        }
601
    }
602
603
    /**
604
     * Join a club
605
     *
606
     * @link    https://strava.github.io/api/v3/clubs/#join
607
     * @param   int $id
608
     * @return  array
609
     * @throws  Exception
610
     */
611 2
    public function joinClub($id)
612
    {
613
        try {
614 2
            return $this->service->joinClub($id);
615 1
        } catch (ServiceException $e) {
616 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
617
        }
618
    }
619
620
    /**
621
     * Leave a club
622
     *
623
     * @link    https://strava.github.io/api/v3/clubs/#leave
624
     * @param   int $id
625
     * @return  array
626
     * @throws  Exception
627
     */
628 2
    public function leaveClub($id)
629
    {
630
        try {
631 2
            return $this->service->leaveClub($id);
632 1
        } catch (ServiceException $e) {
633 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
634
        }
635
    }
636
637
    /**
638
     * Get route details
639
     *
640
     * @link    https://strava.github.io/api/v3/routes/#retreive
641
     * @param   int $id
642
     * @return  array
643
     * @throws  Exception
644
     */
645 2
    public function getRoute($id)
646
    {
647
        try {
648 2
            return $this->service->getRoute($id);
649 1
        } catch (ServiceException $e) {
650 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
651
        }
652
    }
653
    
654
     /**
655
     * Get route list
656
     *
657
     * @link    https://strava.github.io/api/v3/routes/#list
658
     * @param   int $id
0 ignored issues
show
Bug introduced by
There is no parameter named $id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
659
     * @return  array
660
     * @throws  Exception
661
     */
662
    public function getRoutes()
663
    {
664
        try {
665
            return $this->service->getRoutes();
0 ignored issues
show
Bug introduced by
The method getRoutes() does not exist on Strava\API\Service\ServiceInterface. Did you maybe mean getRoute()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
666
        } catch (ServiceException $e) {
667
            throw new ClientException('[SERVICE] ' . $e->getMessage());
668
        }
669
    }
670
671
    /**
672
     * Retrieve a segment
673
     *
674
     * @link    https://strava.github.io/api/v3/segments/#retrieve
675
     * @param   int $id
676
     * @return  array
677
     * @throws  Exception
678
     */
679 2
    public function getSegment($id)
680
    {
681
        try {
682 2
            return $this->service->getSegment($id);
683 1
        } catch (ServiceException $e) {
684 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
685
        }
686
    }
687
688
    /**
689
     * Segment leaderboards
690
     *
691
     * @link    https://strava.github.io/api/v3/segments/#leaderboard
692
     * @param   int $id
693
     * @param   string $gender
694
     * @param   string $age_group
695
     * @param   string $weight_class
696
     * @param   boolean $following
697
     * @param   int $club_id
698
     * @param   string $date_range
699
     * @param   int $context_entries
700
     * @param   int $page
701
     * @param   int $per_page
702
     * @return  array
703
     * @throws  Exception
704
     */
705 2
    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)
706
    {
707
        try {
708 2
            return $this->service->getSegmentLeaderboard($id, $gender, $age_group, $weight_class, $following, $club_id, $date_range, $context_entries, $page, $per_page);
709 1
        } catch (ServiceException $e) {
710 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
711
        }
712
    }
713
714
    /**
715
     * Segment explorer
716
     *
717
     * @link    https://strava.github.io/api/v3/segments/#explore
718
     * @param   string $bounds
719
     * @param   string $activity_type
720
     * @param   int $min_cat
721
     * @param   int $max_cat
722
     * @return  array
723
     * @throws  Exception
724
     */
725 2
    public function getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null)
726
    {
727
        try {
728 2
            return $this->service->getSegmentExplorer($bounds, $activity_type, $min_cat, $max_cat);
729 1
        } catch (ServiceException $e) {
730 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
731
        }
732
    }
733
734
    /**
735
     * List efforts filtered by athlete and/or a date range
736
     *
737
     * @link    https://strava.github.io/api/v3/segments/#efforts
738
     * @param   int $id
739
     * @param   int $athlete_id
740
     * @param   string $start_date_local
741
     * @param   string $end_date_local
742
     * @param   int $page
743
     * @param   int $per_page
744
     * @return  array
745
     * @throws  Exception
746
     */
747 2
    public function getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null)
748
    {
749
        try {
750 2
            return $this->service->getSegmentEffort($id, $athlete_id, $start_date_local, $end_date_local, $page, $per_page);
751 1
        } catch (ServiceException $e) {
752 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
753
        }
754
    }
755
756
    /**
757
     * Retrieve activity streams
758
     *
759
     * @link    https://strava.github.io/api/v3/streams/#activity
760
     * @param   int $id
761
     * @param   string $types
762
     * @param   string $resolution
763
     * @param   string $series_type
764
     * @return  array
765
     * @throws  Exception
766
     */
767 2
    public function getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance')
768
    {
769
        try {
770 2
            return $this->service->getStreamsActivity($id, $types, $resolution, $series_type);
771 1
        } catch (ServiceException $e) {
772 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
773
        }
774
    }
775
776
    /**
777
     * Retrieve effort streams
778
     *
779
     * @link    https://strava.github.io/api/v3/streams/#effort
780
     * @param   int $id
781
     * @param   string $types
782
     * @param   string $resolution
783
     * @param   string $series_type
784
     * @return  array
785
     * @throws  Exception
786
     */
787 2
    public function getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance')
788
    {
789
        try {
790 2
            return $this->service->getStreamsEffort($id, $types, $resolution, $series_type);
791 1
        } catch (ServiceException $e) {
792 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
793
        }
794
    }
795
796
    /**
797
     * Retrieve segment streams
798
     * @link    https://strava.github.io/api/v3/streams/#segment
799
     * @param   int $id
800
     * @param   string $types
801
     * @param   string $resolution
802
     * @param   string $series_type
803
     * @return  array
804
     * @throws  Exception
805
     */
806 2
    public function getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance')
807
    {
808
        try {
809 2
            return $this->service->getStreamsSegment($id, $types, $resolution, $series_type);
810 1
        } catch (ServiceException $e) {
811 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
812
        }
813
    }
814
815
    /**
816
     * Retrieve route streams
817
     *
818
     * @link    https://strava.github.io/api/v3/streams/#routes
819
     * @param   int $id
820
     * @return  array
821
     * @throws  Exception
822
     */
823 2
    public function getStreamsRoute($id)
824
    {
825
        try {
826 2
            return $this->service->getStreamsRoute($id);
827 1
        } catch (ServiceException $e) {
828 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
829
        }
830
    }
831
}
832