Passed
Push — master ( b30ce2...36f187 )
by
unknown
59s queued 11s
created

REST   F

Complexity

Total Complexity 60

Size/Duplication

Total Lines 517
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 98.68%

Importance

Changes 0
Metric Value
wmc 60
lcom 1
cbo 2
dl 0
loc 517
ccs 299
cts 303
cp 0.9868
rs 3.6
c 0
b 0
f 0

46 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
A getToken() 0 4 1
A getResult() 0 15 4
A getResponse() 0 10 2
A getAthlete() 0 9 3
A getAthleteStats() 0 6 1
A getAthleteRoutes() 0 12 1
A getAthleteClubs() 0 6 1
A getAthleteActivities() 0 12 1
A getAthleteFriends() 0 13 3
A getAthleteFollowers() 0 13 3
A getAthleteBothFollowing() 0 10 1
A getAthleteKom() 0 10 1
A getAthleteZones() 0 6 1
A getAthleteStarredSegments() 0 14 3
A updateAthlete() 0 13 1
A getActivity() 0 9 1
A getActivityComments() 0 11 1
A getActivityKudos() 0 10 1
A getActivityPhotos() 0 10 1
A getActivityZones() 0 6 1
A getActivityLaps() 0 6 1
A getActivityUploadStatus() 0 6 1
A createActivity() 0 16 1
A uploadActivity() 0 18 1
A updateActivity() 0 15 1
A deleteActivity() 0 6 1
A getGear() 0 6 1
A getClub() 0 6 1
A getClubMembers() 0 10 1
A getClubActivities() 0 10 1
A getClubAnnouncements() 0 6 1
A getClubGroupEvents() 0 6 1
A joinClub() 0 6 1
A leaveClub() 0 6 1
A getRoute() 0 6 1
A getRouteAsGPX() 0 6 1
A getRouteAsTCX() 0 6 1
A getSegment() 0 6 1
A getSegmentLeaderboard() 0 17 1
A getSegmentExplorer() 0 12 1
A getSegmentEffort() 0 13 1
A getStreamsActivity() 0 10 1
A getStreamsEffort() 0 10 1
A getStreamsSegment() 0 10 1
A getStreamsRoute() 0 6 1

How to fix   Complexity   

Complex Class

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

1
<?php
2
3
namespace Strava\API\Service;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\Psr7\Response;
7
8
/**
9
 * Strava REST Service
10
 *
11
 * @author Bas van Dorst
12
 * @package StravaPHP
13
 */
14
class REST implements ServiceInterface
15
{
16
    /**
17
     * REST adapter
18
     * @var Client
19
     */
20
    protected $adapter;
21
22
    /**
23
     * Application token
24
     * @var string
25
     */
26
    protected $token;
27
28
    /**
29
     * Initiate this REST service with the application token and a instance
30
     * of the REST adapter (Guzzle).
31
     *
32
     * @param string $token
33
     * @param Client $adapter
34
     */
35 47
    public function __construct($token, Client $adapter)
36
    {
37 47
        if (is_object($token) && method_exists($token, 'getToken')) {
38
            $token = $token->getToken();
39
        }
40 47
        $this->token = $token;
41 47
        $this->adapter = $adapter;
42 47
    }
43
44 46
    protected function getToken()
45
    {
46 46
        return $this->token;
47
    }
48
49
    /**
50
     * Get a request result.
51
     * Returns an array with a response body or and error code => reason.
52
     * @param Response $response
53
     * @return array|mixed
54
     */
55 46
    protected function getResult($response)
56
    {
57
        // Workaround for export methods getRouteAsGPX, getRouteAsTCX:
58 46
        if (is_string($response)) {
59 2
            return $response;
60
        }
61
62 44
        $status = $response->getStatusCode();
63
64 44
        if ($status == 200 || $status == 201) {
65 44
            return json_decode($response->getBody(), JSON_PRETTY_PRINT);
66
        } else {
67
            return [$status => $response->getReasonPhrase()];
68
        }
69
    }
70
71
    /**
72
     * Get an API request response and handle possible exceptions.
73
     *
74
     * @param string $method
75
     * @param string $path
76
     * @param array $parameters
77
     *
78
     * @return array|mixed|string
79
     * @throws \GuzzleHttp\Exception\GuzzleException
80
     * @throws \GuzzleHttp\Exception\GuzzleException
81
     */
82 46
    protected function getResponse($method, $path, $parameters)
83
    {
84
        try {
85 46
            $response = $this->adapter->request($method, $path, $parameters);
86 46
            return $this->getResult($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
87
        }
88
        catch (\Exception $e) {
89
            return $e->getMessage();
90
        }
91
    }
92
93 2
    public function getAthlete($id = null)
94
    {
95 2
        $path = 'athlete';
96 2
        if (isset($id) && $id !== null) {
97 1
            $path = 'athletes/' . $id;
98
        }
99 2
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
100 2
        return $this->getResponse('GET', $path, $parameters);
101
    }
102
103 1
    public function getAthleteStats($id)
104
    {
105 1
        $path = 'athletes/' . $id . '/stats';
106 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
107 1
        return $this->getResponse('GET', $path, $parameters);
108
    }
109
110 1
    public function getAthleteRoutes($id, $type = null, $after = null, $page = null, $per_page = null)
111
    {
112 1
        $path = 'athletes/' . $id . '/routes';
113 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
114 1
            'type' => $type,
115 1
            'after' => $after,
116 1
            'page' => $page,
117 1
            'per_page' => $per_page,
118 1
            'access_token' => $this->getToken(),
119
        ];
120 1
        return $this->getResponse('GET', $path, $parameters);
121
    }
122
123 1
    public function getAthleteClubs()
124
    {
125 1
        $path = 'athlete/clubs';
126 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
127 1
        return $this->getResponse('GET', $path, $parameters);
128
    }
129
130 1
    public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null)
131
    {
132 1
        $path = 'athlete/activities';
133 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
134 1
            'before' => $before,
135 1
            'after' => $after,
136 1
            'page' => $page,
137 1
            'per_page' => $per_page,
138 1
            'access_token' => $this->getToken(),
139
        ];
140 1
        return $this->getResponse('GET', $path, $parameters);
141
    }
142
143 2
    public function getAthleteFriends($id = null, $page = null, $per_page = null)
144
    {
145 2
        $path = 'athlete/friends';
146 2
        if (isset($id) && $id !== null) {
147 1
            $path = 'athletes/' . $id . '/friends';
148
        }
149 2
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
150 2
            'page' => $page,
151 2
            'per_page' => $per_page,
152 2
            'access_token' => $this->getToken(),
153
        ];
154 2
        return $this->getResponse('GET', $path, $parameters);
155
    }
156
157 2
    public function getAthleteFollowers($id = null, $page = null, $per_page = null)
158
    {
159 2
        $path = 'athlete/followers';
160 2
        if (isset($id) && $id !== null) {
161 1
            $path = 'athletes/' . $id . '/followers';
162
        }
163 2
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
164 2
            'page' => $page,
165 2
            'per_page' => $per_page,
166 2
            'access_token' => $this->getToken(),
167
        ];
168 2
        return $this->getResponse('GET', $path, $parameters);
169
    }
170
171 1
    public function getAthleteBothFollowing($id, $page = null, $per_page = null)
172
    {
173 1
        $path = 'athletes/' . $id . '/both-following';
174 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
175 1
            'page' => $page,
176 1
            'per_page' => $per_page,
177 1
            'access_token' => $this->getToken(),
178
        ];
179 1
        return $this->getResponse('GET', $path, $parameters);
180
    }
181
182 1
    public function getAthleteKom($id, $page = null, $per_page = null)
183
    {
184 1
        $path = 'athletes/' . $id . '/koms';
185 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
186 1
            'page' => $page,
187 1
            'per_page' => $per_page,
188 1
            'access_token' => $this->getToken(),
189
        ];
190 1
        return $this->getResponse('GET', $path, $parameters);
191
    }
192
193 1
    public function getAthleteZones()
194
    {
195 1
        $path = 'athlete/zones';
196 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
197 1
        return $this->getResponse('GET', $path, $parameters);
198
    }
199
200 2
    public function getAthleteStarredSegments($id = null, $page = null, $per_page = null)
201
    {
202 2
        $path = 'segments/starred';
203 2
        if (isset($id) && $id !== null) {
204 1
            $path = 'athletes/' . $id . '/segments/starred';
205
            // ...wrong in Strava documentation
206
        }
207 2
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
208 2
            'page' => $page,
209 2
            'per_page' => $per_page,
210 2
            'access_token' => $this->getToken(),
211
        ];
212 2
        return $this->getResponse('GET', $path, $parameters);
213
    }
214
215 1
    public function updateAthlete($city, $state, $country, $sex, $weight)
216
    {
217 1
        $path = 'athlete';
218 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
219 1
            'city' => $city,
220 1
            'state' => $state,
221 1
            'country' => $country,
222 1
            'sex' => $sex,
223 1
            'weight' => $weight,
224 1
            'access_token' => $this->getToken(),
225
        ];
226 1
        return $this->getResponse('PUT', $path, $parameters);
227
    }
228
229 1
    public function getActivity($id, $include_all_efforts = null)
230
    {
231 1
        $path = 'activities/' . $id;
232 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
233 1
            'include_all_efforts' => $include_all_efforts,
234 1
            'access_token' => $this->getToken(),
235
        ];
236 1
        return $this->getResponse('GET', $path, $parameters);
237
    }
238
239 1
    public function getActivityComments($id, $markdown = null, $page = null, $per_page = null)
240
    {
241 1
        $path = 'activities/' . $id . '/comments';
242 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
243 1
            'markdown' => $markdown,
244 1
            'page' => $page,
245 1
            'per_page' => $per_page,
246 1
            'access_token' => $this->getToken(),
247
        ];
248 1
        return $this->getResponse('GET', $path, $parameters);
249
    }
250
251 1
    public function getActivityKudos($id, $page = null, $per_page = null)
252
    {
253 1
        $path = 'activities/' . $id . '/kudos';
254 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
255 1
            'page' => $page,
256 1
            'per_page' => $per_page,
257 1
            'access_token' => $this->getToken(),
258
        ];
259 1
        return $this->getResponse('GET', $path, $parameters);
260
    }
261
262 1
    public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true')
263
    {
264 1
        $path = 'activities/' . $id . '/photos';
265 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
266 1
            'size' => $size,
267 1
            'photo_sources' => $photo_sources,
268 1
            'access_token' => $this->getToken(),
269
        ];
270 1
        return $this->getResponse('GET', $path, $parameters);
271
    }
272
273 1
    public function getActivityZones($id)
274
    {
275 1
        $path = 'activities/' . $id . '/zones';
276 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
277 1
        return $this->getResponse('GET', $path, $parameters);
278
    }
279
280 1
    public function getActivityLaps($id)
281
    {
282 1
        $path = 'activities/' . $id . '/laps';
283 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
284 1
        return $this->getResponse('GET', $path, $parameters);
285
    }
286
287 1
    public function getActivityUploadStatus($id)
288
    {
289 1
        $path = 'uploads/' . $id;
290 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
291 1
        return $this->getResponse('GET', $path, $parameters);
292
    }
293
294 1
    public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null, $private = null, $trainer = null)
295
    {
296 1
        $path = 'activities';
297 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
298 1
            'name' => $name,
299 1
            'type' => $type,
300 1
            'start_date_local' => $start_date_local,
301 1
            'elapsed_time' => $elapsed_time,
302 1
            'description' => $description,
303 1
            'distance' => $distance,
304 1
            'private' => $private,
305 1
            'trainer' => $trainer,
306 1
            'access_token' => $this->getToken(),
307
        ];
308 1
        return $this->getResponse('POST', $path, $parameters);
309
    }
310
311 1
    public function uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $trainer = null, $commute = null, $data_type = null, $external_id = null)
312
    {
313 1
        $path = 'uploads';
314 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
315 1
            'activity_type' => $activity_type,
316 1
            'name' => $name,
317 1
            'description' => $description,
318 1
            'private' => $private,
319 1
            'trainer' => $trainer,
320 1
            'commute' => $commute,
321 1
            'data_type' => $data_type,
322 1
            'external_id' => $external_id,
323 1
            'file' => curl_file_create($file),
324 1
            'file_hack' => '@' . ltrim($file, '@'),
325 1
            'access_token' => $this->getToken(),
326
        ];
327 1
        return $this->getResponse('POST', $path, $parameters);
328
    }
329
330 1
    public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null)
331
    {
332 1
        $path = 'activities/' . $id;
333 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
334 1
            'name' => $name,
335 1
            'type' => $type,
336 1
            'private' => $private,
337 1
            'commute' => $commute,
338 1
            'trainer' => $trainer,
339 1
            'gear_id' => $gear_id,
340 1
            'description' => $description,
341 1
            'access_token' => $this->getToken(),
342
        ];
343 1
        return $this->getResponse('PUT', $path, $parameters);
344
    }
345
346 1
    public function deleteActivity($id)
347
    {
348 1
        $path = 'activities/' . $id;
349 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
350 1
        return $this->getResponse('DELETE', $path, $parameters);
351
    }
352
353 1
    public function getGear($id)
354
    {
355 1
        $path = 'gear/' . $id;
356 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
357 1
        return $this->getResponse('GET', $path, $parameters);
358
    }
359
360 1
    public function getClub($id)
361
    {
362 1
        $path = 'clubs/' . $id;
363 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
364 1
        return $this->getResponse('GET', $path, $parameters);
365
    }
366
367 1
    public function getClubMembers($id, $page = null, $per_page = null)
368
    {
369 1
        $path = 'clubs/' . $id . '/members';
370 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
371 1
            'page' => $page,
372 1
            'per_page' => $per_page,
373 1
            'access_token' => $this->getToken(),
374
        ];
375 1
        return $this->getResponse('GET', $path, $parameters);
376
    }
377
378 1
    public function getClubActivities($id, $page = null, $per_page = null)
379
    {
380 1
        $path = 'clubs/' . $id . '/activities';
381 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
382 1
            'page' => $page,
383 1
            'per_page' => $per_page,
384 1
            'access_token' => $this->getToken(),
385
        ];
386 1
        return $this->getResponse('GET', $path, $parameters);
387
    }
388
389 1
    public function getClubAnnouncements($id)
390
    {
391 1
        $path = 'clubs/' . $id . '/announcements';
392 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
393 1
        return $this->getResponse('GET', $path, $parameters);
394
    }
395
396 1
    public function getClubGroupEvents($id)
397
    {
398 1
        $path = 'clubs/' . $id . '/group_events';
399 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
400 1
        return $this->getResponse('GET', $path, $parameters);
401
    }
402
403 1
    public function joinClub($id)
404
    {
405 1
        $path = 'clubs/' . $id . '/join';
406 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
407 1
        return $this->getResponse('POST', $path, $parameters);
408
    }
409
410 1
    public function leaveClub($id)
411
    {
412 1
        $path = 'clubs/' . $id . '/leave';
413 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
414 1
        return $this->getResponse('POST', $path, $parameters);
415
    }
416
417 1
    public function getRoute($id)
418
    {
419 1
        $path = 'routes/' . $id;
420 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
421 1
        return $this->getResponse('GET', $path, $parameters);
422
    }
423
424 1
    public function getRouteAsGPX($id)
425
    {
426 1
        $path = 'routes/' . $id . '/export_gpx';
427 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
428 1
        return $this->getResponse('GET', $path, $parameters);
429
    }
430
431 1
    public function getRouteAsTCX($id)
432
    {
433 1
        $path = 'routes/' . $id . '/export_tcx';
434 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
435 1
        return $this->getResponse('GET', $path, $parameters);
436
    }
437
438 1
    public function getSegment($id)
439
    {
440 1
        $path = 'segments/' . $id;
441 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
442 1
        return $this->getResponse('GET', $path, $parameters);
443
    }
444
445 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)
446
    {
447 1
        $path = 'segments/' . $id . '/leaderboard';
448 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
449 1
            'gender' => $gender,
450 1
            'age_group' => $age_group,
451 1
            'weight_class' => $weight_class,
452 1
            'following' => $following,
453 1
            'club_id' => $club_id,
454 1
            'date_range' => $date_range,
455 1
            'context_entries' => $context_entries,
456 1
            'page' => $page,
457 1
            'per_page' => $per_page,
458 1
            'access_token' => $this->getToken(),
459
        ];
460 1
        return $this->getResponse('GET', $path, $parameters);
461
    }
462
463 1
    public function getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null)
464
    {
465 1
        $path = 'segments/explore';
466 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
467 1
            'bounds' => $bounds,
468 1
            'activity_type' => $activity_type,
469 1
            'min_cat' => $min_cat,
470 1
            'max_cat' => $max_cat,
471 1
            'access_token' => $this->getToken(),
472
        ];
473 1
        return $this->getResponse('GET', $path, $parameters);
474
    }
475
476 1
    public function getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null)
477
    {
478 1
        $path = 'segments/' . $id . '/all_efforts';
479 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
480 1
            'athlete_id' => $athlete_id,
481 1
            'start_date_local' => $start_date_local,
482 1
            'end_date_local' => $end_date_local,
483 1
            'page' => $page,
484 1
            'per_page' => $per_page,
485 1
            'access_token' => $this->getToken(),
486
        ];
487 1
        return $this->getResponse('GET', $path, $parameters);
488
    }
489
490 1
    public function getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance')
491
    {
492 1
        $path = 'activities/' . $id . '/streams/' . $types;
493 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
494 1
            'resolution' => $resolution,
495 1
            'series_type' => $series_type,
496 1
            'access_token' => $this->getToken(),
497
        ];
498 1
        return $this->getResponse('GET', $path, $parameters);
499
    }
500
501 1
    public function getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance')
502
    {
503 1
        $path = 'segment_efforts/' . $id . '/streams/' . $types;
504 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
505 1
            'resolution' => $resolution,
506 1
            'series_type' => $series_type,
507 1
            'access_token' => $this->getToken(),
508
        ];
509 1
        return $this->getResponse('GET', $path, $parameters);
510
    }
511
512 1
    public function getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance')
513
    {
514 1
        $path = 'segments/' . $id . '/streams/' . $types;
515 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
516 1
            'resolution' => $resolution,
517 1
            'series_type' => $series_type,
518 1
            'access_token' => $this->getToken(),
519
        ];
520 1
        return $this->getResponse('GET', $path, $parameters);
521
    }
522
523 1
    public function getStreamsRoute($id)
524
    {
525 1
        $path = 'routes/' . $id . '/streams';
526 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
527 1
        return $this->getResponse('GET', $path, $parameters);
528
    }
529
530
}
531