Passed
Pull Request — master (#67)
by
unknown
01:58
created

REST   F

Complexity

Total Complexity 100

Size/Duplication

Total Lines 694
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 86.77%

Importance

Changes 0
Metric Value
wmc 100
lcom 1
cbo 2
dl 0
loc 694
ccs 374
cts 431
cp 0.8677
rs 1.906
c 0
b 0
f 0

46 Methods

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

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
     * Specifies the verbosity of the HTTP response
30
     * 0 = basic, just body
31
     * 1 = enhanced, [body, headers, status]
32
     * @var int|mixed
33
     */
34
    protected $responseVerbosity;
35
36
    /**
37
     * Initiate this REST service with the application token and a instance
38
     * of the REST adapter (Guzzle).
39
     *
40
     * @param string $token
41
     * @param Client $adapter
42
     */
43 45
    public function __construct($token, Client $adapter, $responseVerbosity = 0)
44
    {
45 45
        if (is_object($token) && method_exists($token, 'getToken')) {
46
            $token = $token->getToken();
47
        }
48 45
        $this->token = $token;
49 45
        $this->adapter = $adapter;
50 45
        $this->responseVerbosity = $responseVerbosity;
51 45
    }
52
53 44
    protected function getToken()
54
    {
55 44
        return $this->token;
56
    }
57
58
    /**
59
     * Get a request result.
60
     * Returns an array with a response body or and error code => reason.
61
     * @param Response $response
62
     * @return array|mixed
63
     */
64 44
    protected function getResult($response)
65
    {
66 44
        $status = $response->getStatusCode();
67
68 44
        $expandedResponse = [];
69
70 44
        $expandedResponse['headers'] = $response->getHeaders();
71 44
        $expandedResponse['body'] = json_decode($response->getBody(), JSON_PRETTY_PRINT);
72 44
        $expandedResponse['success'] = $status == 200 || $status == 201;
73 44
        $expandedResponse['status'] = $status;
74
75 44
        return $expandedResponse;
76
    }
77
78
    /**
79
     * Get an API request response and handle possible exceptions.
80
     *
81
     * @param string $method
82
     * @param string $path
83
     * @param array $parameters
84
     *
85
     * @return array|mixed|string
86
     * @throws \GuzzleHttp\Exception\GuzzleException
87
     * @throws \GuzzleHttp\Exception\GuzzleException
88
     */
89 44
    protected function getResponse($method, $path, $parameters)
90
    {
91
        try {
92 44
            $response = $this->adapter->request($method, $path, $parameters);
93 44
            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...
94
        }
95
        catch (\Exception $e) {
96
            return $e->getMessage();
97
        }
98
    }
99
100 2
    public function getAthlete($id = null)
101
    {
102 2
        $path = 'athlete';
103 2
        if (isset($id) && $id !== null) {
104 1
            $path = 'athletes/' . $id;
105
        }
106 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...
107
108 2
        $response = $this->getResponse('GET', $path, $parameters);
109
110 2
        if ($this->responseVerbosity == 0)
111 2
            return $response["body"];
112
113
        return $response;
114
    }
115
116 1
    public function getAthleteStats($id)
117
    {
118 1
        $path = 'athletes/' . $id . '/stats';
119 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...
120 1
        $response = $this->getResponse('GET', $path, $parameters);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->getResponse('GET', $path, $parameters); of type array|string adds the type string to the return on line 124 which is incompatible with the return type declared by the interface Strava\API\Service\Servi...erface::getAthleteStats of type array.
Loading history...
121
122 1
        if ($this->responseVerbosity == 0)
123 1
            return $response['body'];
124
        return $response;
125
    }
126
127 1
    public function getAthleteRoutes($id, $type = null, $after = null, $page = null, $per_page = null)
128
    {
129 1
        $path = 'athletes/' . $id . '/routes';
130 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...
131 1
            'type' => $type,
132 1
            'after' => $after,
133 1
            'page' => $page,
134 1
            'per_page' => $per_page,
135 1
            'access_token' => $this->getToken(),
136
        ];
137 1
        $response = $this->getResponse('GET', $path, $parameters);
138
139 1
        if ($this->responseVerbosity == 0)
140 1
            return $response['body'];
141
        return $response;
142
    }
143
144 1
    public function getAthleteClubs()
145
    {
146 1
        $path = 'athlete/clubs';
147 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...
148 1
        $response = $this->getResponse('GET', $path, $parameters);
149
150 1
        if ($this->responseVerbosity == 0)
151 1
            return $response['body'];
152
        return $response;
153
    }
154
155 1
    public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null)
156
    {
157 1
        $path = 'athlete/activities';
158 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...
159 1
            'before' => $before,
160 1
            'after' => $after,
161 1
            'page' => $page,
162 1
            'per_page' => $per_page,
163 1
            'access_token' => $this->getToken(),
164
        ];
165 1
        $response = $this->getResponse('GET', $path, $parameters);
166
167 1
        if ($this->responseVerbosity == 0)
168 1
            return $response['body'];
169
        return $response;
170
    }
171
172 2
    public function getAthleteFriends($id = null, $page = null, $per_page = null)
173
    {
174 2
        $path = 'athlete/friends';
175 2
        if (isset($id) && $id !== null) {
176 1
            $path = 'athletes/' . $id . '/friends';
177
        }
178 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...
179 2
            'page' => $page,
180 2
            'per_page' => $per_page,
181 2
            'access_token' => $this->getToken(),
182
        ];
183 2
        $response = $this->getResponse('GET', $path, $parameters);
184
185 2
        if ($this->responseVerbosity == 0)
186 2
            return $response['body'];
187
        return $response;
188
    }
189
190 2
    public function getAthleteFollowers($id = null, $page = null, $per_page = null)
191
    {
192 2
        $path = 'athlete/followers';
193 2
        if (isset($id) && $id !== null) {
194 1
            $path = 'athletes/' . $id . '/followers';
195
        }
196 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...
197 2
            'page' => $page,
198 2
            'per_page' => $per_page,
199 2
            'access_token' => $this->getToken(),
200
        ];
201 2
        $response = $this->getResponse('GET', $path, $parameters);
202
203 2
        if ($this->responseVerbosity == 0)
204 2
            return $response['body'];
205
        return $response;
206
    }
207
208 1
    public function getAthleteBothFollowing($id, $page = null, $per_page = null)
209
    {
210 1
        $path = 'athletes/' . $id . '/both-following';
211 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...
212 1
            'page' => $page,
213 1
            'per_page' => $per_page,
214 1
            'access_token' => $this->getToken(),
215
        ];
216 1
        $response = $this->getResponse('GET', $path, $parameters);
217
218 1
        if ($this->responseVerbosity == 0)
219 1
            return $response['body'];
220
        return $response;
221
    }
222
223 1
    public function getAthleteKom($id, $page = null, $per_page = null)
224
    {
225 1
        $path = 'athletes/' . $id . '/koms';
226 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...
227 1
            'page' => $page,
228 1
            'per_page' => $per_page,
229 1
            'access_token' => $this->getToken(),
230
        ];
231 1
        $response = $this->getResponse('GET', $path, $parameters);
232
233 1
        if ($this->responseVerbosity == 0)
234 1
            return $response['body'];
235
        return $response;
236
    }
237
238 1
    public function getAthleteZones()
239
    {
240 1
        $path = 'athlete/zones';
241 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...
242 1
        $response = $this->getResponse('GET', $path, $parameters);
243
244 1
        if ($this->responseVerbosity == 0)
245 1
            return $response['body'];
246
        return $response;
247
    }
248
249 2
    public function getAthleteStarredSegments($id = null, $page = null, $per_page = null)
250
    {
251 2
        $path = 'segments/starred';
252 2
        if (isset($id) && $id !== null) {
253 1
            $path = 'athletes/' . $id . '/segments/starred';
254
            // ...wrong in Strava documentation
255
        }
256 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...
257 2
            'page' => $page,
258 2
            'per_page' => $per_page,
259 2
            'access_token' => $this->getToken(),
260
        ];
261 2
        $response = $this->getResponse('GET', $path, $parameters);
262
263 2
        if ($this->responseVerbosity == 0)
264 2
            return $response['body'];
265
        return $response;
266
    }
267
268 1
    public function updateAthlete($city, $state, $country, $sex, $weight)
269
    {
270 1
        $path = 'athlete';
271 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...
272 1
            'city' => $city,
273 1
            'state' => $state,
274 1
            'country' => $country,
275 1
            'sex' => $sex,
276 1
            'weight' => $weight,
277 1
            'access_token' => $this->getToken(),
278
        ];
279 1
        $response = $this->getResponse('PUT', $path, $parameters);
280
281 1
        if ($this->responseVerbosity == 0)
282 1
            return $response['body'];
283
        return $response;
284
    }
285
286 1
    public function getActivity($id, $include_all_efforts = null)
287
    {
288 1
        $path = 'activities/' . $id;
289 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...
290 1
            'include_all_efforts' => $include_all_efforts,
291 1
            'access_token' => $this->getToken(),
292
        ];
293 1
        $response = $this->getResponse('GET', $path, $parameters);
294
295 1
        if ($this->responseVerbosity == 0)
296 1
            return $response['body'];
297
        return $response;
298
    }
299
300 1
    public function getActivityComments($id, $markdown = null, $page = null, $per_page = null)
301
    {
302 1
        $path = 'activities/' . $id . '/comments';
303 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...
304 1
            'markdown' => $markdown,
305 1
            'page' => $page,
306 1
            'per_page' => $per_page,
307 1
            'access_token' => $this->getToken(),
308
        ];
309 1
        $response = $this->getResponse('GET', $path, $parameters);
310
311 1
        if ($this->responseVerbosity == 0)
312 1
            return $response['body'];
313
        return $response;
314
    }
315
316 1
    public function getActivityKudos($id, $page = null, $per_page = null)
317
    {
318 1
        $path = 'activities/' . $id . '/kudos';
319 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...
320 1
            'page' => $page,
321 1
            'per_page' => $per_page,
322 1
            'access_token' => $this->getToken(),
323
        ];
324 1
        $response = $this->getResponse('GET', $path, $parameters);
325
326 1
        if ($this->responseVerbosity == 0)
327 1
            return $response['body'];
328
        return $response;
329
    }
330
331 1
    public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true')
332
    {
333 1
        $path = 'activities/' . $id . '/photos';
334 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...
335 1
            'size' => $size,
336 1
            'photo_sources' => $photo_sources,
337 1
            'access_token' => $this->getToken(),
338
        ];
339 1
        $response = $this->getResponse('GET', $path, $parameters);
340
341 1
        if ($this->responseVerbosity == 0)
342 1
            return $response['body'];
343
        return $response;
344
    }
345
346 1
    public function getActivityZones($id)
347
    {
348 1
        $path = 'activities/' . $id . '/zones';
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
        $response = $this->getResponse('GET', $path, $parameters);
351
352 1
        if ($this->responseVerbosity == 0)
353 1
            return $response['body'];
354
        return $response;
355
    }
356
357 1
    public function getActivityLaps($id)
358
    {
359 1
        $path = 'activities/' . $id . '/laps';
360 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...
361 1
        $response = $this->getResponse('GET', $path, $parameters);
362
363 1
        if ($this->responseVerbosity == 0)
364 1
            return $response['body'];
365
        return $response;
366
    }
367
368 1
    public function getActivityUploadStatus($id)
369
    {
370 1
        $path = 'uploads/' . $id;
371 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...
372 1
        $response = $this->getResponse('GET', $path, $parameters);
373
374 1
        if ($this->responseVerbosity == 0)
375 1
            return $response['body'];
376
        return $response;
377
    }
378
379 1
    public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null, $private = null, $trainer = null)
380
    {
381 1
        $path = 'activities';
382 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...
383 1
            'name' => $name,
384 1
            'type' => $type,
385 1
            'start_date_local' => $start_date_local,
386 1
            'elapsed_time' => $elapsed_time,
387 1
            'description' => $description,
388 1
            'distance' => $distance,
389 1
            'private' => $private,
390 1
            'trainer' => $trainer,
391 1
            'access_token' => $this->getToken(),
392
        ];
393 1
        $response = $this->getResponse('POST', $path, $parameters);
394
395 1
        if ($this->responseVerbosity == 0)
396 1
            return $response['body'];
397
        return $response;
398
    }
399
400 1
    public function uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $trainer = null, $commute = null, $data_type = null, $external_id = null)
401
    {
402 1
        $path = 'uploads';
403 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...
404 1
            'activity_type' => $activity_type,
405 1
            'name' => $name,
406 1
            'description' => $description,
407 1
            'private' => $private,
408 1
            'trainer' => $trainer,
409 1
            'commute' => $commute,
410 1
            'data_type' => $data_type,
411 1
            'external_id' => $external_id,
412 1
            'file' => curl_file_create($file),
413 1
            'file_hack' => '@' . ltrim($file, '@'),
414 1
            'access_token' => $this->getToken(),
415
        ];
416 1
        $response = $this->getResponse('POST', $path, $parameters);
417
418 1
        if ($this->responseVerbosity == 0)
419 1
            return $response['body'];
420
        return $response;
421
    }
422
423 1
    public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null)
424
    {
425 1
        $path = 'activities/' . $id;
426 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...
427 1
            'name' => $name,
428 1
            'type' => $type,
429 1
            'private' => $private,
430 1
            'commute' => $commute,
431 1
            'trainer' => $trainer,
432 1
            'gear_id' => $gear_id,
433 1
            'description' => $description,
434 1
            'access_token' => $this->getToken(),
435
        ];
436 1
        $response = $this->getResponse('PUT', $path, $parameters);
437
438 1
        if ($this->responseVerbosity == 0)
439 1
            return $response['body'];
440
        return $response;
441
    }
442
443 1
    public function deleteActivity($id)
444
    {
445 1
        $path = 'activities/' . $id;
446 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...
447 1
        $response = $this->getResponse('DELETE', $path, $parameters);
448
449 1
        if ($this->responseVerbosity == 0)
450 1
            return $response['body'];
451
        return $response;
452
    }
453
454 1
    public function getGear($id)
455
    {
456 1
        $path = 'gear/' . $id;
457 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...
458 1
        $response = $this->getResponse('GET', $path, $parameters);
459
460 1
        if ($this->responseVerbosity == 0)
461 1
            return $response['body'];
462
        return $response;
463
    }
464
465 1
    public function getClub($id)
466
    {
467 1
        $path = 'clubs/' . $id;
468 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...
469 1
        $response = $this->getResponse('GET', $path, $parameters);
470
471 1
        if ($this->responseVerbosity == 0)
472 1
            return $response['body'];
473
        return $response;
474
    }
475
476 1
    public function getClubMembers($id, $page = null, $per_page = null)
477
    {
478 1
        $path = 'clubs/' . $id . '/members';
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
            'page' => $page,
481 1
            'per_page' => $per_page,
482 1
            'access_token' => $this->getToken(),
483
        ];
484 1
        $response = $this->getResponse('GET', $path, $parameters);
485
486 1
        if ($this->responseVerbosity == 0)
487 1
            return $response['body'];
488
        return $response;
489
    }
490
491 1
    public function getClubActivities($id, $page = null, $per_page = null)
492
    {
493 1
        $path = 'clubs/' . $id . '/activities';
494 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...
495 1
            'page' => $page,
496 1
            'per_page' => $per_page,
497 1
            'access_token' => $this->getToken(),
498
        ];
499 1
        $response = $this->getResponse('GET', $path, $parameters);
500
501 1
        if ($this->responseVerbosity == 0)
502 1
            return $response['body'];
503
        return $response;
504
    }
505
506 1
    public function getClubAnnouncements($id)
507
    {
508 1
        $path = 'clubs/' . $id . '/announcements';
509 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...
510 1
        $response = $this->getResponse('GET', $path, $parameters);
511
512 1
        if ($this->responseVerbosity == 0)
513 1
            return $response['body'];
514
        return $response;
515
    }
516
517 1
    public function getClubGroupEvents($id)
518
    {
519 1
        $path = 'clubs/' . $id . '/group_events';
520 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...
521 1
        $response = $this->getResponse('GET', $path, $parameters);
522
523 1
        if ($this->responseVerbosity == 0)
524 1
            return $response['body'];
525
        return $response;
526
    }
527
528 1
    public function joinClub($id)
529
    {
530 1
        $path = 'clubs/' . $id . '/join';
531 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...
532 1
        $response = $this->getResponse('POST', $path, $parameters);
533
534 1
        if ($this->responseVerbosity == 0)
535 1
            return $response['body'];
536
        return $response;
537
    }
538
539 1
    public function leaveClub($id)
540
    {
541 1
        $path = 'clubs/' . $id . '/leave';
542 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...
543 1
        $response = $this->getResponse('POST', $path, $parameters);
544
545 1
        if ($this->responseVerbosity == 0)
546 1
            return $response['body'];
547
        return $response;
548
    }
549
550 1
    public function getRoute($id)
551
    {
552 1
        $path = 'routes/' . $id;
553 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...
554 1
        $response = $this->getResponse('GET', $path, $parameters);
555
556 1
        if ($this->responseVerbosity == 0)
557 1
            return $response['body'];
558
        return $response;
559
    }
560
561
    public function getRouteAsGPX($id)
562
    {
563
        $path = 'routes/' . $id . '/export_gpx';
564
        $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...
565
        $response = $this->getResponse('GET', $path, $parameters);
566
567
        if ($this->responseVerbosity == 0)
568
            return $response['body'];
569
        return $response;
570
    }
571
572
    public function getRouteAsTCX($id)
573
    {
574
        $path = 'routes/' . $id . '/export_tcx';
575
        $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...
576
        $response = $this->getResponse('GET', $path, $parameters);
577
578
        if ($this->responseVerbosity == 0)
579
            return $response['body'];
580
        return $response;
581
    }
582
583 1
    public function getSegment($id)
584
    {
585 1
        $path = 'segments/' . $id;
586 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...
587 1
        $response = $this->getResponse('GET', $path, $parameters);
588
589 1
        if ($this->responseVerbosity == 0)
590 1
            return $response['body'];
591
        return $response;
592
    }
593
594 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)
595
    {
596 1
        $path = 'segments/' . $id . '/leaderboard';
597 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...
598 1
            'gender' => $gender,
599 1
            'age_group' => $age_group,
600 1
            'weight_class' => $weight_class,
601 1
            'following' => $following,
602 1
            'club_id' => $club_id,
603 1
            'date_range' => $date_range,
604 1
            'context_entries' => $context_entries,
605 1
            'page' => $page,
606 1
            'per_page' => $per_page,
607 1
            'access_token' => $this->getToken(),
608
        ];
609 1
        $response = $this->getResponse('GET', $path, $parameters);
610
611 1
        if ($this->responseVerbosity == 0)
612 1
            return $response['body'];
613
        return $response;
614
    }
615
616 1
    public function getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null)
617
    {
618 1
        $path = 'segments/explore';
619 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...
620 1
            'bounds' => $bounds,
621 1
            'activity_type' => $activity_type,
622 1
            'min_cat' => $min_cat,
623 1
            'max_cat' => $max_cat,
624 1
            'access_token' => $this->getToken(),
625
        ];
626 1
        $response = $this->getResponse('GET', $path, $parameters);
627
628 1
        if ($this->responseVerbosity == 0)
629 1
            return $response['body'];
630
        return $response;
631
    }
632
633 1
    public function getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null)
634
    {
635 1
        $path = 'segments/' . $id . '/all_efforts';
636 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...
637 1
            'athlete_id' => $athlete_id,
638 1
            'start_date_local' => $start_date_local,
639 1
            'end_date_local' => $end_date_local,
640 1
            'page' => $page,
641 1
            'per_page' => $per_page,
642 1
            'access_token' => $this->getToken(),
643
        ];
644 1
        $response = $this->getResponse('GET', $path, $parameters);
645
646 1
        if ($this->responseVerbosity == 0)
647 1
            return $response['body'];
648
        return $response;
649
    }
650
651 1
    public function getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance')
652
    {
653 1
        $path = 'activities/' . $id . '/streams/' . $types;
654 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...
655 1
            'resolution' => $resolution,
656 1
            'series_type' => $series_type,
657 1
            'access_token' => $this->getToken(),
658
        ];
659 1
        $response = $this->getResponse('GET', $path, $parameters);
660
661 1
        if ($this->responseVerbosity == 0)
662 1
            return $response['body'];
663
        return $response;
664
    }
665
666 1
    public function getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance')
667
    {
668 1
        $path = 'segment_efforts/' . $id . '/streams/' . $types;
669 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...
670 1
            'resolution' => $resolution,
671 1
            'series_type' => $series_type,
672 1
            'access_token' => $this->getToken(),
673
        ];
674 1
        $response = $this->getResponse('GET', $path, $parameters);
675
676 1
        if ($this->responseVerbosity == 0)
677 1
            return $response['body'];
678
        return $response;
679
    }
680
681 1
    public function getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance')
682
    {
683 1
        $path = 'segments/' . $id . '/streams/' . $types;
684 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...
685 1
            'resolution' => $resolution,
686 1
            'series_type' => $series_type,
687 1
            'access_token' => $this->getToken(),
688
        ];
689 1
        $response = $this->getResponse('GET', $path, $parameters);
690
691 1
        if ($this->responseVerbosity == 0)
692 1
            return $response['body'];
693
        return $response;
694
    }
695
696 1
    public function getStreamsRoute($id)
697
    {
698 1
        $path = 'routes/' . $id . '/streams';
699 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...
700 1
        $response = $this->getResponse('GET', $path, $parameters);
701
702 1
        if ($this->responseVerbosity == 0)
703 1
            return $response['body'];
704
        return $response;
705
    }
706
707
}
708