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

REST   F

Complexity

Total Complexity 100

Size/Duplication

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