Passed
Push — master ( ac77f2...791946 )
by
unknown
27:26 queued 11s
created

REST::getAthlete()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
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
     */
94 46
    protected function getResponse($method, $path, $parameters)
95
    {
96
        try {
97 46
            $response = $this->adapter->request($method, $path, $parameters);
98 46
            $result = $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...
99
100 46
            if ($this->responseVerbosity === 0)
101 46
                return $result["body"];
102
103 44
            return $result;
104
        }
105 2
        catch (\Exception $e) {
106 2
            return $e->getMessage();
107
        }
108
    }
109
110 2
    public function getAthlete($id = null)
111
    {
112 2
        $path = 'athlete';
113 2
        if (isset($id)) {
114 1
            $path = 'athletes/' . $id;
115
        }
116 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...
117
118 2
        return $this->getResponse('GET', $path, $parameters);
119
    }
120
121 1
    public function getAthleteStats($id)
122
    {
123 1
        $path = 'athletes/' . $id . '/stats';
124 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...
125
126 1
        return $this->getResponse('GET', $path, $parameters);
127
    }
128
129 1
    public function getAthleteRoutes($id, $type = null, $after = null, $page = null, $per_page = null)
130
    {
131 1
        $path = 'athletes/' . $id . '/routes';
132 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...
133 1
            'type' => $type,
134 1
            'after' => $after,
135 1
            'page' => $page,
136 1
            'per_page' => $per_page,
137 1
            'access_token' => $this->getToken(),
138
        ];
139
140 1
        return $this->getResponse('GET', $path, $parameters);
141
    }
142
143 1
    public function getAthleteClubs()
144
    {
145 1
        $path = 'athlete/clubs';
146 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...
147
148 1
        return $this->getResponse('GET', $path, $parameters);
149
    }
150
151 1
    public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null)
152
    {
153 1
        $path = 'athlete/activities';
154 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...
155 1
            'before' => $before,
156 1
            'after' => $after,
157 1
            'page' => $page,
158 1
            'per_page' => $per_page,
159 1
            'access_token' => $this->getToken(),
160
        ];
161
162 1
        return $this->getResponse('GET', $path, $parameters);
163
    }
164
165 2
    public function getAthleteFriends($id = null, $page = null, $per_page = null)
166
    {
167 2
        $path = 'athlete/friends';
168 2
        if (isset($id)) {
169 1
            $path = 'athletes/' . $id . '/friends';
170
        }
171 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...
172 2
            'page' => $page,
173 2
            'per_page' => $per_page,
174 2
            'access_token' => $this->getToken(),
175
        ];
176
177 2
        return $this->getResponse('GET', $path, $parameters);
178
    }
179
180 2
    public function getAthleteFollowers($id = null, $page = null, $per_page = null)
181
    {
182 2
        $path = 'athlete/followers';
183 2
        if (isset($id)) {
184 1
            $path = 'athletes/' . $id . '/followers';
185
        }
186 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...
187 2
            'page' => $page,
188 2
            'per_page' => $per_page,
189 2
            'access_token' => $this->getToken(),
190
        ];
191
192 2
        return $this->getResponse('GET', $path, $parameters);
193
    }
194
195 1
    public function getAthleteBothFollowing($id, $page = null, $per_page = null)
196
    {
197 1
        $path = 'athletes/' . $id . '/both-following';
198 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...
199 1
            'page' => $page,
200 1
            'per_page' => $per_page,
201 1
            'access_token' => $this->getToken(),
202
        ];
203
204 1
        return $this->getResponse('GET', $path, $parameters);
205
    }
206
207 1
    public function getAthleteKom($id, $page = null, $per_page = null)
208
    {
209 1
        $path = 'athletes/' . $id . '/koms';
210 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...
211 1
            'page' => $page,
212 1
            'per_page' => $per_page,
213 1
            'access_token' => $this->getToken(),
214
        ];
215
216 1
        return $this->getResponse('GET', $path, $parameters);
217
    }
218
219 1
    public function getAthleteZones()
220
    {
221 1
        $path = 'athlete/zones';
222 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...
223
224 1
        return $this->getResponse('GET', $path, $parameters);
225
    }
226
227 2
    public function getAthleteStarredSegments($id = null, $page = null, $per_page = null)
228
    {
229 2
        $path = 'segments/starred';
230 2
        if (isset($id)) {
231 1
            $path = 'athletes/' . $id . '/segments/starred';
232
            // ...wrong in Strava documentation
233
        }
234 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...
235 2
            'page' => $page,
236 2
            'per_page' => $per_page,
237 2
            'access_token' => $this->getToken(),
238
        ];
239
240 2
        return $this->getResponse('GET', $path, $parameters);
241
    }
242
243 1
    public function updateAthlete($city, $state, $country, $sex, $weight)
244
    {
245 1
        $path = 'athlete';
246 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...
247 1
            'city' => $city,
248 1
            'state' => $state,
249 1
            'country' => $country,
250 1
            'sex' => $sex,
251 1
            'weight' => $weight,
252 1
            'access_token' => $this->getToken(),
253
        ];
254
255 1
        return $this->getResponse('PUT', $path, $parameters);
256
    }
257
258 1
    public function getActivity($id, $include_all_efforts = null)
259
    {
260 1
        $path = 'activities/' . $id;
261 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...
262 1
            'include_all_efforts' => $include_all_efforts,
263 1
            'access_token' => $this->getToken(),
264
        ];
265
266 1
        return $this->getResponse('GET', $path, $parameters);
267
    }
268
269 1
    public function getActivityComments($id, $markdown = null, $page = null, $per_page = null)
270
    {
271 1
        $path = 'activities/' . $id . '/comments';
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
            'markdown' => $markdown,
274 1
            'page' => $page,
275 1
            'per_page' => $per_page,
276 1
            'access_token' => $this->getToken(),
277
        ];
278
279 1
        return $this->getResponse('GET', $path, $parameters);
280
    }
281
282 1
    public function getActivityKudos($id, $page = null, $per_page = null)
283
    {
284 1
        $path = 'activities/' . $id . '/kudos';
285 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...
286 1
            'page' => $page,
287 1
            'per_page' => $per_page,
288 1
            'access_token' => $this->getToken(),
289
        ];
290
291 1
        return $this->getResponse('GET', $path, $parameters);
292
    }
293
294 1
    public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true')
295
    {
296 1
        $path = 'activities/' . $id . '/photos';
297 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

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

Let’s take a look at an example:

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

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

    // do something with $myArray
}

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

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

Loading history...
298 1
            'size' => $size,
299 1
            'photo_sources' => $photo_sources,
300 1
            'access_token' => $this->getToken(),
301
        ];
302
303 1
        return $this->getResponse('GET', $path, $parameters);
304
    }
305
306 1
    public function getActivityZones($id)
307
    {
308 1
        $path = 'activities/' . $id . '/zones';
309 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...
310
311 1
        return $this->getResponse('GET', $path, $parameters);
312
    }
313
314 1
    public function getActivityLaps($id)
315
    {
316 1
        $path = 'activities/' . $id . '/laps';
317 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...
318
319 1
        return $this->getResponse('GET', $path, $parameters);
320
    }
321
322 1
    public function getActivityUploadStatus($id)
323
    {
324 1
        $path = 'uploads/' . $id;
325 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...
326
327 1
        return $this->getResponse('GET', $path, $parameters);
328
    }
329
330 1
    public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null, $private = null, $trainer = null)
331
    {
332 1
        $path = 'activities';
333 1
        $parameters['query'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

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

Let’s take a look at an example:

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

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

    // do something with $myArray
}

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

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

Loading history...
334 1
            'name' => $name,
335 1
            'type' => $type,
336 1
            'start_date_local' => $start_date_local,
337 1
            'elapsed_time' => $elapsed_time,
338 1
            'description' => $description,
339 1
            'distance' => $distance,
340 1
            'private' => $private,
341 1
            'trainer' => $trainer,
342 1
            'access_token' => $this->getToken(),
343
        ];
344
345 1
        return $this->getResponse('POST', $path, $parameters);
346
    }
347
348 1
    public function uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $trainer = null, $commute = null, $data_type = null, $external_id = null)
349
    {
350 1
        $path = 'uploads';
351 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...
352 1
            'activity_type' => $activity_type,
353 1
            'name' => $name,
354 1
            'description' => $description,
355 1
            'private' => $private,
356 1
            'trainer' => $trainer,
357 1
            'commute' => $commute,
358 1
            'data_type' => $data_type,
359 1
            'external_id' => $external_id,
360 1
            'file' => curl_file_create($file),
361 1
            'file_hack' => '@' . ltrim($file, '@'),
362 1
            'access_token' => $this->getToken(),
363
        ];
364
365 1
        return $this->getResponse('POST', $path, $parameters);
366
    }
367
368 1
    public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null)
369
    {
370 1
        $path = 'activities/' . $id;
371 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...
372 1
            'name' => $name,
373 1
            'type' => $type,
374 1
            'private' => $private,
375 1
            'commute' => $commute,
376 1
            'trainer' => $trainer,
377 1
            'gear_id' => $gear_id,
378 1
            'description' => $description,
379 1
            'access_token' => $this->getToken(),
380
        ];
381
382 1
        return $this->getResponse('PUT', $path, $parameters);
383
    }
384
385 1
    public function deleteActivity($id)
386
    {
387 1
        $path = 'activities/' . $id;
388 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...
389
390 1
        return $this->getResponse('DELETE', $path, $parameters);
391
    }
392
393 1
    public function getGear($id)
394
    {
395 1
        $path = 'gear/' . $id;
396 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...
397
398 1
        return $this->getResponse('GET', $path, $parameters);
399
    }
400
401 1
    public function getClub($id)
402
    {
403 1
        $path = 'clubs/' . $id;
404 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...
405
406 1
        return $this->getResponse('GET', $path, $parameters);
407
    }
408
409 1
    public function getClubMembers($id, $page = null, $per_page = null)
410
    {
411 1
        $path = 'clubs/' . $id . '/members';
412 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...
413 1
            'page' => $page,
414 1
            'per_page' => $per_page,
415 1
            'access_token' => $this->getToken(),
416
        ];
417
418 1
        return $this->getResponse('GET', $path, $parameters);
419
    }
420
421 1
    public function getClubActivities($id, $page = null, $per_page = null)
422
    {
423 1
        $path = 'clubs/' . $id . '/activities';
424 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...
425 1
            'page' => $page,
426 1
            'per_page' => $per_page,
427 1
            'access_token' => $this->getToken(),
428
        ];
429
430 1
        return $this->getResponse('GET', $path, $parameters);
431
    }
432
433 1
    public function getClubAnnouncements($id)
434
    {
435 1
        $path = 'clubs/' . $id . '/announcements';
436 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...
437
438 1
        return $this->getResponse('GET', $path, $parameters);
439
    }
440
441 1
    public function getClubGroupEvents($id)
442
    {
443 1
        $path = 'clubs/' . $id . '/group_events';
444 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...
445
446 1
        return $this->getResponse('GET', $path, $parameters);
447
    }
448
449 1
    public function joinClub($id)
450
    {
451 1
        $path = 'clubs/' . $id . '/join';
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
454 1
        return $this->getResponse('POST', $path, $parameters);
455
    }
456
457 1
    public function leaveClub($id)
458
    {
459 1
        $path = 'clubs/' . $id . '/leave';
460 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...
461
462 1
        return $this->getResponse('POST', $path, $parameters);
463
    }
464
465 1
    public function getRoute($id)
466
    {
467 1
        $path = 'routes/' . $id;
468 1
        $parameters['query'] = ['access_token' => $this->getToken()];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.

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

Let’s take a look at an example:

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

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

    // do something with $myArray
}

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

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

Loading history...
469
470 1
        return $this->getResponse('GET', $path, $parameters);
471
    }
472
473 1
    public function getRouteAsGPX($id)
474
    {
475 1
        $path = 'routes/' . $id . '/export_gpx';
476 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...
477
478 1
        return $this->getResponse('GET', $path, $parameters);
479
    }
480
481 1
    public function getRouteAsTCX($id)
482
    {
483 1
        $path = 'routes/' . $id . '/export_tcx';
484 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...
485
486 1
        return $this->getResponse('GET', $path, $parameters);
487
    }
488
489 1
    public function getSegment($id)
490
    {
491 1
        $path = 'segments/' . $id;
492 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...
493
494 1
        return $this->getResponse('GET', $path, $parameters);
495
    }
496
497 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)
498
    {
499 1
        $path = 'segments/' . $id . '/leaderboard';
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
            'gender' => $gender,
502 1
            'age_group' => $age_group,
503 1
            'weight_class' => $weight_class,
504 1
            'following' => $following,
505 1
            'club_id' => $club_id,
506 1
            'date_range' => $date_range,
507 1
            'context_entries' => $context_entries,
508 1
            'page' => $page,
509 1
            'per_page' => $per_page,
510 1
            'access_token' => $this->getToken(),
511
        ];
512
513 1
        return $this->getResponse('GET', $path, $parameters);
514
    }
515
516 1
    public function getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null)
517
    {
518 1
        $path = 'segments/explore';
519 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...
520 1
            'bounds' => $bounds,
521 1
            'activity_type' => $activity_type,
522 1
            'min_cat' => $min_cat,
523 1
            'max_cat' => $max_cat,
524 1
            'access_token' => $this->getToken(),
525
        ];
526
527 1
        return $this->getResponse('GET', $path, $parameters);
528
    }
529
530 1
    public function getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null)
531
    {
532 1
        $path = 'segments/' . $id . '/all_efforts';
533 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...
534 1
            'athlete_id' => $athlete_id,
535 1
            'start_date_local' => $start_date_local,
536 1
            'end_date_local' => $end_date_local,
537 1
            'page' => $page,
538 1
            'per_page' => $per_page,
539 1
            'access_token' => $this->getToken(),
540
        ];
541
542 1
        return $this->getResponse('GET', $path, $parameters);
543
    }
544
545 1
    public function getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance')
546
    {
547 1
        $path = 'activities/' . $id . '/streams/' . $types;
548 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...
549 1
            'resolution' => $resolution,
550 1
            'series_type' => $series_type,
551 1
            'access_token' => $this->getToken(),
552
        ];
553
554 1
        return $this->getResponse('GET', $path, $parameters);
555
    }
556
557 1
    public function getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance')
558
    {
559 1
        $path = 'segment_efforts/' . $id . '/streams/' . $types;
560 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...
561 1
            'resolution' => $resolution,
562 1
            'series_type' => $series_type,
563 1
            'access_token' => $this->getToken(),
564
        ];
565
566 1
        return $this->getResponse('GET', $path, $parameters);
567
    }
568
569 1
    public function getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance')
570
    {
571 1
        $path = 'segments/' . $id . '/streams/' . $types;
572 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...
573 1
            'resolution' => $resolution,
574 1
            'series_type' => $series_type,
575 1
            'access_token' => $this->getToken(),
576
        ];
577
578 1
        return $this->getResponse('GET', $path, $parameters);
579
    }
580
581 1
    public function getStreamsRoute($id)
582
    {
583 1
        $path = 'routes/' . $id . '/streams';
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
586 1
        return $this->getResponse('GET', $path, $parameters);
587
    }
588
589
}
590