Passed
Push — master ( 36f187...ac77f2 )
by
unknown
56s queued 10s
created

REST::getSegmentEffort()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 13
cts 13
cp 1
rs 9.7
c 0
b 0
f 0
cc 2
nc 2
nop 6
crap 2
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 47
    public function __construct($token, Client $adapter, $responseVerbosity = 0)
45
    {
46 47
        if (is_object($token) && method_exists($token, 'getToken')) {
47
            $token = $token->getToken();
48
        }
49 47
        $this->token = $token;
50 47
        $this->adapter = $adapter;
51 47
        $this->responseVerbosity = $responseVerbosity;
52 47
    }
53
54 46
    protected function getToken()
55
    {
56 46
        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 46
    protected function getResult($response)
66
    {
67
        // Workaround for export methods getRouteAsGPX, getRouteAsTCX:
68 46
        if (is_string($response)) {
69 2
            return $response;
70
        }
71
72 44
        $status = $response->getStatusCode();
73
74 44
        $expandedResponse = [];
75
76 44
        $expandedResponse['headers'] = $response->getHeaders();
77 44
        $expandedResponse['body'] = json_decode($response->getBody(), JSON_PRETTY_PRINT);
78 44
        $expandedResponse['success'] = $status === 200 || $status === 201;
79 44
        $expandedResponse['status'] = $status;
80
81 44
        return $expandedResponse;
82
    }
83
84
    /**
85
     * Get an API request response and handle possible exceptions.
86
     *
87
     * @param string $method
88
     * @param string $path
89
     * @param array $parameters
90
     *
91
     * @return array|mixed|string
92
     * @throws \GuzzleHttp\Exception\GuzzleException
93
     * @throws \GuzzleHttp\Exception\GuzzleException
94
     */
95 46
    protected function getResponse($method, $path, $parameters)
96
    {
97
        try {
98 46
            $response = $this->adapter->request($method, $path, $parameters);
99 46
            return $this->getResult($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

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

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

Loading history...
100
        }
101
        catch (\Exception $e) {
102
            return $e->getMessage();
103
        }
104
    }
105
106 2
    public function getAthlete($id = null)
107
    {
108 2
        $path = 'athlete';
109 2
        if (isset($id) && $id !== null) {
110 1
            $path = 'athletes/' . $id;
111
        }
112 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...
113
114 2
        $response = $this->getResponse('GET', $path, $parameters);
115
116 2
        if ($this->responseVerbosity === 0)
117 2
            return $response["body"];
118
119 2
        return $response;
120
    }
121
122 1
    public function getAthleteStats($id)
123
    {
124 1
        $path = 'athletes/' . $id . '/stats';
125 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...
126 1
        $response = $this->getResponse('GET', $path, $parameters);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->getResponse('GET', $path, $parameters); of type string|array adds the type string to the return on line 130 which is incompatible with the return type declared by the interface Strava\API\Service\Servi...erface::getAthleteStats of type array.
Loading history...
127
128 1
        if ($this->responseVerbosity === 0)
129 1
            return $response['body'];
130 1
        return $response;
131
    }
132
133 1
    public function getAthleteRoutes($id, $type = null, $after = null, $page = null, $per_page = null)
134
    {
135 1
        $path = 'athletes/' . $id . '/routes';
136 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...
137 1
            'type' => $type,
138 1
            'after' => $after,
139 1
            'page' => $page,
140 1
            'per_page' => $per_page,
141 1
            'access_token' => $this->getToken(),
142
        ];
143 1
        $response = $this->getResponse('GET', $path, $parameters);
144
145 1
        if ($this->responseVerbosity === 0)
146 1
            return $response['body'];
147 1
        return $response;
148
    }
149
150 1
    public function getAthleteClubs()
151
    {
152 1
        $path = 'athlete/clubs';
153 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...
154 1
        $response = $this->getResponse('GET', $path, $parameters);
155
156 1
        if ($this->responseVerbosity === 0)
157 1
            return $response['body'];
158 1
        return $response;
159
    }
160
161 1
    public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null)
162
    {
163 1
        $path = 'athlete/activities';
164 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...
165 1
            'before' => $before,
166 1
            'after' => $after,
167 1
            'page' => $page,
168 1
            'per_page' => $per_page,
169 1
            'access_token' => $this->getToken(),
170
        ];
171 1
        $response = $this->getResponse('GET', $path, $parameters);
172
173 1
        if ($this->responseVerbosity === 0)
174 1
            return $response['body'];
175 1
        return $response;
176
    }
177
178 2
    public function getAthleteFriends($id = null, $page = null, $per_page = null)
179
    {
180 2
        $path = 'athlete/friends';
181 2
        if (isset($id) && $id !== null) {
182 1
            $path = 'athletes/' . $id . '/friends';
183
        }
184 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...
185 2
            'page' => $page,
186 2
            'per_page' => $per_page,
187 2
            'access_token' => $this->getToken(),
188
        ];
189 2
        $response = $this->getResponse('GET', $path, $parameters);
190
191 2
        if ($this->responseVerbosity === 0)
192 2
            return $response['body'];
193 2
        return $response;
194
    }
195
196 2
    public function getAthleteFollowers($id = null, $page = null, $per_page = null)
197
    {
198 2
        $path = 'athlete/followers';
199 2
        if (isset($id) && $id !== null) {
200 1
            $path = 'athletes/' . $id . '/followers';
201
        }
202 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...
203 2
            'page' => $page,
204 2
            'per_page' => $per_page,
205 2
            'access_token' => $this->getToken(),
206
        ];
207 2
        $response = $this->getResponse('GET', $path, $parameters);
208
209 2
        if ($this->responseVerbosity === 0)
210 2
            return $response['body'];
211 2
        return $response;
212
    }
213
214 1
    public function getAthleteBothFollowing($id, $page = null, $per_page = null)
215
    {
216 1
        $path = 'athletes/' . $id . '/both-following';
217 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...
218 1
            'page' => $page,
219 1
            'per_page' => $per_page,
220 1
            'access_token' => $this->getToken(),
221
        ];
222 1
        $response = $this->getResponse('GET', $path, $parameters);
223
224 1
        if ($this->responseVerbosity === 0)
225 1
            return $response['body'];
226 1
        return $response;
227
    }
228
229 1
    public function getAthleteKom($id, $page = null, $per_page = null)
230
    {
231 1
        $path = 'athletes/' . $id . '/koms';
232 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

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

Let’s take a look at an example:

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

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

    // do something with $myArray
}

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

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

Loading history...
233 1
            'page' => $page,
234 1
            'per_page' => $per_page,
235 1
            'access_token' => $this->getToken(),
236
        ];
237 1
        $response = $this->getResponse('GET', $path, $parameters);
238
239 1
        if ($this->responseVerbosity === 0)
240 1
            return $response['body'];
241 1
        return $response;
242
    }
243
244 1
    public function getAthleteZones()
245
    {
246 1
        $path = 'athlete/zones';
247 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...
248 1
        $response = $this->getResponse('GET', $path, $parameters);
249
250 1
        if ($this->responseVerbosity === 0)
251 1
            return $response['body'];
252 1
        return $response;
253
    }
254
255 2
    public function getAthleteStarredSegments($id = null, $page = null, $per_page = null)
256
    {
257 2
        $path = 'segments/starred';
258 2
        if (isset($id) && $id !== null) {
259 1
            $path = 'athletes/' . $id . '/segments/starred';
260
            // ...wrong in Strava documentation
261
        }
262 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...
263 2
            'page' => $page,
264 2
            'per_page' => $per_page,
265 2
            'access_token' => $this->getToken(),
266
        ];
267 2
        $response = $this->getResponse('GET', $path, $parameters);
268
269 2
        if ($this->responseVerbosity === 0)
270 2
            return $response['body'];
271 2
        return $response;
272
    }
273
274 1
    public function updateAthlete($city, $state, $country, $sex, $weight)
275
    {
276 1
        $path = 'athlete';
277 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...
278 1
            'city' => $city,
279 1
            'state' => $state,
280 1
            'country' => $country,
281 1
            'sex' => $sex,
282 1
            'weight' => $weight,
283 1
            'access_token' => $this->getToken(),
284
        ];
285 1
        $response = $this->getResponse('PUT', $path, $parameters);
286
287 1
        if ($this->responseVerbosity === 0)
288 1
            return $response['body'];
289 1
        return $response;
290
    }
291
292 1
    public function getActivity($id, $include_all_efforts = null)
293
    {
294 1
        $path = 'activities/' . $id;
295 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...
296 1
            'include_all_efforts' => $include_all_efforts,
297 1
            'access_token' => $this->getToken(),
298
        ];
299 1
        $response = $this->getResponse('GET', $path, $parameters);
300
301 1
        if ($this->responseVerbosity === 0)
302 1
            return $response['body'];
303 1
        return $response;
304
    }
305
306 1
    public function getActivityComments($id, $markdown = null, $page = null, $per_page = null)
307
    {
308 1
        $path = 'activities/' . $id . '/comments';
309 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...
310 1
            'markdown' => $markdown,
311 1
            'page' => $page,
312 1
            'per_page' => $per_page,
313 1
            'access_token' => $this->getToken(),
314
        ];
315 1
        $response = $this->getResponse('GET', $path, $parameters);
316
317 1
        if ($this->responseVerbosity === 0)
318 1
            return $response['body'];
319 1
        return $response;
320
    }
321
322 1
    public function getActivityKudos($id, $page = null, $per_page = null)
323
    {
324 1
        $path = 'activities/' . $id . '/kudos';
325 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...
326 1
            'page' => $page,
327 1
            'per_page' => $per_page,
328 1
            'access_token' => $this->getToken(),
329
        ];
330 1
        $response = $this->getResponse('GET', $path, $parameters);
331
332 1
        if ($this->responseVerbosity === 0)
333 1
            return $response['body'];
334 1
        return $response;
335
    }
336
337 1
    public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true')
338
    {
339 1
        $path = 'activities/' . $id . '/photos';
340 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...
341 1
            'size' => $size,
342 1
            'photo_sources' => $photo_sources,
343 1
            'access_token' => $this->getToken(),
344
        ];
345 1
        $response = $this->getResponse('GET', $path, $parameters);
346
347 1
        if ($this->responseVerbosity === 0)
348 1
            return $response['body'];
349 1
        return $response;
350
    }
351
352 1
    public function getActivityZones($id)
353
    {
354 1
        $path = 'activities/' . $id . '/zones';
355 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...
356 1
        $response = $this->getResponse('GET', $path, $parameters);
357
358 1
        if ($this->responseVerbosity === 0)
359 1
            return $response['body'];
360 1
        return $response;
361
    }
362
363 1
    public function getActivityLaps($id)
364
    {
365 1
        $path = 'activities/' . $id . '/laps';
366 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...
367 1
        $response = $this->getResponse('GET', $path, $parameters);
368
369 1
        if ($this->responseVerbosity === 0)
370 1
            return $response['body'];
371 1
        return $response;
372
    }
373
374 1
    public function getActivityUploadStatus($id)
375
    {
376 1
        $path = 'uploads/' . $id;
377 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...
378 1
        $response = $this->getResponse('GET', $path, $parameters);
379
380 1
        if ($this->responseVerbosity === 0)
381 1
            return $response['body'];
382 1
        return $response;
383
    }
384
385 1
    public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null, $private = null, $trainer = null)
386
    {
387 1
        $path = 'activities';
388 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...
389 1
            'name' => $name,
390 1
            'type' => $type,
391 1
            'start_date_local' => $start_date_local,
392 1
            'elapsed_time' => $elapsed_time,
393 1
            'description' => $description,
394 1
            'distance' => $distance,
395 1
            'private' => $private,
396 1
            'trainer' => $trainer,
397 1
            'access_token' => $this->getToken(),
398
        ];
399 1
        $response = $this->getResponse('POST', $path, $parameters);
400
401 1
        if ($this->responseVerbosity === 0)
402 1
            return $response['body'];
403 1
        return $response;
404
    }
405
406 1
    public function uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $trainer = null, $commute = null, $data_type = null, $external_id = null)
407
    {
408 1
        $path = 'uploads';
409 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...
410 1
            'activity_type' => $activity_type,
411 1
            'name' => $name,
412 1
            'description' => $description,
413 1
            'private' => $private,
414 1
            'trainer' => $trainer,
415 1
            'commute' => $commute,
416 1
            'data_type' => $data_type,
417 1
            'external_id' => $external_id,
418 1
            'file' => curl_file_create($file),
419 1
            'file_hack' => '@' . ltrim($file, '@'),
420 1
            'access_token' => $this->getToken(),
421
        ];
422 1
        $response = $this->getResponse('POST', $path, $parameters);
423
424 1
        if ($this->responseVerbosity === 0)
425 1
            return $response['body'];
426 1
        return $response;
427
    }
428
429 1
    public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null)
430
    {
431 1
        $path = 'activities/' . $id;
432 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...
433 1
            'name' => $name,
434 1
            'type' => $type,
435 1
            'private' => $private,
436 1
            'commute' => $commute,
437 1
            'trainer' => $trainer,
438 1
            'gear_id' => $gear_id,
439 1
            'description' => $description,
440 1
            'access_token' => $this->getToken(),
441
        ];
442 1
        $response = $this->getResponse('PUT', $path, $parameters);
443
444 1
        if ($this->responseVerbosity === 0)
445 1
            return $response['body'];
446 1
        return $response;
447
    }
448
449 1
    public function deleteActivity($id)
450
    {
451 1
        $path = 'activities/' . $id;
452 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...
453 1
        $response = $this->getResponse('DELETE', $path, $parameters);
454
455 1
        if ($this->responseVerbosity === 0)
456 1
            return $response['body'];
457 1
        return $response;
458
    }
459
460 1
    public function getGear($id)
461
    {
462 1
        $path = 'gear/' . $id;
463 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...
464 1
        $response = $this->getResponse('GET', $path, $parameters);
465
466 1
        if ($this->responseVerbosity === 0)
467 1
            return $response['body'];
468 1
        return $response;
469
    }
470
471 1
    public function getClub($id)
472
    {
473 1
        $path = 'clubs/' . $id;
474 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...
475 1
        $response = $this->getResponse('GET', $path, $parameters);
476
477 1
        if ($this->responseVerbosity === 0)
478 1
            return $response['body'];
479 1
        return $response;
480
    }
481
482 1
    public function getClubMembers($id, $page = null, $per_page = null)
483
    {
484 1
        $path = 'clubs/' . $id . '/members';
485 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...
486 1
            'page' => $page,
487 1
            'per_page' => $per_page,
488 1
            'access_token' => $this->getToken(),
489
        ];
490 1
        $response = $this->getResponse('GET', $path, $parameters);
491
492 1
        if ($this->responseVerbosity === 0)
493 1
            return $response['body'];
494 1
        return $response;
495
    }
496
497 1
    public function getClubActivities($id, $page = null, $per_page = null)
498
    {
499 1
        $path = 'clubs/' . $id . '/activities';
500 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...
501 1
            'page' => $page,
502 1
            'per_page' => $per_page,
503 1
            'access_token' => $this->getToken(),
504
        ];
505 1
        $response = $this->getResponse('GET', $path, $parameters);
506
507 1
        if ($this->responseVerbosity === 0)
508 1
            return $response['body'];
509 1
        return $response;
510
    }
511
512 1
    public function getClubAnnouncements($id)
513
    {
514 1
        $path = 'clubs/' . $id . '/announcements';
515 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...
516 1
        $response = $this->getResponse('GET', $path, $parameters);
517
518 1
        if ($this->responseVerbosity === 0)
519 1
            return $response['body'];
520 1
        return $response;
521
    }
522
523 1
    public function getClubGroupEvents($id)
524
    {
525 1
        $path = 'clubs/' . $id . '/group_events';
526 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

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

Let’s take a look at an example:

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

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

    // do something with $myArray
}

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

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

Loading history...
527 1
        $response = $this->getResponse('GET', $path, $parameters);
528
529 1
        if ($this->responseVerbosity === 0)
530 1
            return $response['body'];
531 1
        return $response;
532
    }
533
534 1
    public function joinClub($id)
535
    {
536 1
        $path = 'clubs/' . $id . '/join';
537 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...
538 1
        $response = $this->getResponse('POST', $path, $parameters);
539
540 1
        if ($this->responseVerbosity === 0)
541 1
            return $response['body'];
542 1
        return $response;
543
    }
544
545 1
    public function leaveClub($id)
546
    {
547 1
        $path = 'clubs/' . $id . '/leave';
548 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...
549 1
        $response = $this->getResponse('POST', $path, $parameters);
550
551 1
        if ($this->responseVerbosity === 0)
552 1
            return $response['body'];
553 1
        return $response;
554
    }
555
556 1
    public function getRoute($id)
557
    {
558 1
        $path = 'routes/' . $id;
559 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...
560 1
        $response = $this->getResponse('GET', $path, $parameters);
561
562 1
        if ($this->responseVerbosity === 0)
563 1
            return $response['body'];
564 1
        return $response;
565
    }
566
567 1
    public function getRouteAsGPX($id)
568
    {
569 1
        $path = 'routes/' . $id . '/export_gpx';
570 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...
571 1
        return $this->getResponse('GET', $path, $parameters);
572
    }
573
574 1
    public function getRouteAsTCX($id)
575
    {
576 1
        $path = 'routes/' . $id . '/export_tcx';
577 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...
578 1
        return $this->getResponse('GET', $path, $parameters);
579
    }
580
581 1
    public function getSegment($id)
582
    {
583 1
        $path = 'segments/' . $id;
584 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...
585 1
        $response = $this->getResponse('GET', $path, $parameters);
586
587 1
        if ($this->responseVerbosity === 0)
588 1
            return $response['body'];
589 1
        return $response;
590
    }
591
592 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)
593
    {
594 1
        $path = 'segments/' . $id . '/leaderboard';
595 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...
596 1
            'gender' => $gender,
597 1
            'age_group' => $age_group,
598 1
            'weight_class' => $weight_class,
599 1
            'following' => $following,
600 1
            'club_id' => $club_id,
601 1
            'date_range' => $date_range,
602 1
            'context_entries' => $context_entries,
603 1
            'page' => $page,
604 1
            'per_page' => $per_page,
605 1
            'access_token' => $this->getToken(),
606
        ];
607 1
        $response = $this->getResponse('GET', $path, $parameters);
608
609 1
        if ($this->responseVerbosity === 0)
610 1
            return $response['body'];
611 1
        return $response;
612
    }
613
614 1
    public function getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null)
615
    {
616 1
        $path = 'segments/explore';
617 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...
618 1
            'bounds' => $bounds,
619 1
            'activity_type' => $activity_type,
620 1
            'min_cat' => $min_cat,
621 1
            'max_cat' => $max_cat,
622 1
            'access_token' => $this->getToken(),
623
        ];
624 1
        $response = $this->getResponse('GET', $path, $parameters);
625
626 1
        if ($this->responseVerbosity === 0)
627 1
            return $response['body'];
628 1
        return $response;
629
    }
630
631 1
    public function getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null)
632
    {
633 1
        $path = 'segments/' . $id . '/all_efforts';
634 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...
635 1
            'athlete_id' => $athlete_id,
636 1
            'start_date_local' => $start_date_local,
637 1
            'end_date_local' => $end_date_local,
638 1
            'page' => $page,
639 1
            'per_page' => $per_page,
640 1
            'access_token' => $this->getToken(),
641
        ];
642 1
        $response = $this->getResponse('GET', $path, $parameters);
643
644 1
        if ($this->responseVerbosity === 0)
645 1
            return $response['body'];
646 1
        return $response;
647
    }
648
649 1
    public function getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance')
650
    {
651 1
        $path = 'activities/' . $id . '/streams/' . $types;
652 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...
653 1
            'resolution' => $resolution,
654 1
            'series_type' => $series_type,
655 1
            'access_token' => $this->getToken(),
656
        ];
657 1
        $response = $this->getResponse('GET', $path, $parameters);
658
659 1
        if ($this->responseVerbosity === 0)
660 1
            return $response['body'];
661 1
        return $response;
662
    }
663
664 1
    public function getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance')
665
    {
666 1
        $path = 'segment_efforts/' . $id . '/streams/' . $types;
667 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...
668 1
            'resolution' => $resolution,
669 1
            'series_type' => $series_type,
670 1
            'access_token' => $this->getToken(),
671
        ];
672 1
        $response = $this->getResponse('GET', $path, $parameters);
673
674 1
        if ($this->responseVerbosity === 0)
675 1
            return $response['body'];
676 1
        return $response;
677
    }
678
679 1
    public function getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance')
680
    {
681 1
        $path = 'segments/' . $id . '/streams/' . $types;
682 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...
683 1
            'resolution' => $resolution,
684 1
            'series_type' => $series_type,
685 1
            'access_token' => $this->getToken(),
686
        ];
687 1
        $response = $this->getResponse('GET', $path, $parameters);
688
689 1
        if ($this->responseVerbosity === 0)
690 1
            return $response['body'];
691 1
        return $response;
692
    }
693
694 1
    public function getStreamsRoute($id)
695
    {
696 1
        $path = 'routes/' . $id . '/streams';
697 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...
698 1
        $response = $this->getResponse('GET', $path, $parameters);
699
700 1
        if ($this->responseVerbosity === 0)
701 1
            return $response['body'];
702 1
        return $response;
703
    }
704
705
}
706