GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DirectionLeg::addStep()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMap\Service\Direction\Response;
13
14
use Ivory\GoogleMap\Base\Coordinate;
15
use Ivory\GoogleMap\Service\Base\Distance;
16
use Ivory\GoogleMap\Service\Base\Duration;
17
use Ivory\GoogleMap\Service\Base\Time;
18
19
/**
20
 * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionLeg
21
 *
22
 * @author GeLo <[email protected]>
23
 */
24
class DirectionLeg
25
{
26
    /**
27
     * @var Distance|null
28
     */
29
    private $distance;
30
31
    /**
32
     * @var Duration|null
33
     */
34
    private $duration;
35
36
    /**
37
     * @var Duration|null
38
     */
39
    private $durationInTraffic;
40
41
    /**
42
     * @var Time|null
43
     */
44
    private $arrivalTime;
45
46
    /**
47
     * @var Time|null
48
     */
49
    private $departureTime;
50
51
    /**
52
     * @var string|null
53
     */
54
    private $endAddress;
55
56
    /**
57
     * @var Coordinate|null
58
     */
59
    private $endLocation;
60
61
    /**
62
     * @var string|null
63
     */
64
    private $startAddress;
65
66
    /**
67
     * @var Coordinate|null
68
     */
69
    private $startLocation;
70
71
    /**
72
     * @var DirectionStep[]
73
     */
74
    private $steps = [];
75
76
    /**
77
     * @var DirectionWaypoint[]
78
     */
79
    private $viaWaypoints = [];
80
81
    /**
82
     * @return bool
83
     */
84 12
    public function hasDistance()
85
    {
86 12
        return $this->distance !== null;
87
    }
88
89
    /**
90
     * @return Distance|null
91
     */
92 276
    public function getDistance()
93
    {
94 276
        return $this->distance;
95
    }
96
97
    /**
98
     * @param Distance|null $distance
99
     */
100 8
    public function setDistance(Distance $distance = null)
101
    {
102 8
        $this->distance = $distance;
103 8
    }
104
105
    /**
106
     * @return bool
107
     */
108 12
    public function hasDuration()
109
    {
110 12
        return $this->duration !== null;
111
    }
112
113
    /**
114
     * @return Duration|null
115
     */
116 276
    public function getDuration()
117
    {
118 276
        return $this->duration;
119
    }
120
121
    /**
122
     * @param Duration|null $duration
123
     */
124 8
    public function setDuration(Duration $duration = null)
125
    {
126 8
        $this->duration = $duration;
127 8
    }
128
129
    /**
130
     * @return bool
131
     */
132 12
    public function hasDurationInTraffic()
133
    {
134 12
        return $this->durationInTraffic !== null;
135
    }
136
137
    /**
138
     * @return Duration|null
139
     */
140 276
    public function getDurationInTraffic()
141
    {
142 276
        return $this->durationInTraffic;
143
    }
144
145
    /**
146
     * @param Duration|null $durationInTraffic
147
     */
148 8
    public function setDurationInTraffic(Duration $durationInTraffic = null)
149
    {
150 8
        $this->durationInTraffic = $durationInTraffic;
151 8
    }
152
153
    /**
154
     * @return bool
155
     */
156 12
    public function hasArrivalTime()
157
    {
158 12
        return $this->arrivalTime !== null;
159
    }
160
161
    /**
162
     * @return Time|null
163
     */
164 276
    public function getArrivalTime()
165
    {
166 276
        return $this->arrivalTime;
167
    }
168
169
    /**
170
     * @param Time|null $arrivalTime
171
     */
172 8
    public function setArrivalTime(Time $arrivalTime = null)
173
    {
174 8
        $this->arrivalTime = $arrivalTime;
175 8
    }
176
177
    /**
178
     * @return bool
179
     */
180 12
    public function hasDepartureTime()
181
    {
182 12
        return $this->departureTime !== null;
183
    }
184
185
    /**
186
     * @return Time|null
187
     */
188 276
    public function getDepartureTime()
189
    {
190 276
        return $this->departureTime;
191
    }
192
193
    /**
194
     * @param Time|null $departureTime
195
     */
196 8
    public function setDepartureTime(Time $departureTime = null)
197
    {
198 8
        $this->departureTime = $departureTime;
199 8
    }
200
201
    /**
202
     * @return bool
203
     */
204 12
    public function hasEndAddress()
205
    {
206 12
        return $this->endAddress !== null;
207
    }
208
209
    /**
210
     * @return string|null
211
     */
212 276
    public function getEndAddress()
213
    {
214 276
        return $this->endAddress;
215
    }
216
217
    /**
218
     * @param string|null $endAddress
219
     */
220 8
    public function setEndAddress($endAddress = null)
221
    {
222 8
        $this->endAddress = $endAddress;
223 8
    }
224
225
    /**
226
     * @return bool
227
     */
228 12
    public function hasEndLocation()
229
    {
230 12
        return $this->endLocation !== null;
231
    }
232
233
    /**
234
     * @return Coordinate|null
235
     */
236 276
    public function getEndLocation()
237
    {
238 276
        return $this->endLocation;
239
    }
240
241
    /**
242
     * @param Coordinate|null $endLocation
243
     */
244 8
    public function setEndLocation(Coordinate $endLocation = null)
245
    {
246 8
        $this->endLocation = $endLocation;
247 8
    }
248
249
    /**
250
     * @return bool
251
     */
252 12
    public function hasStartAddress()
253
    {
254 12
        return $this->startAddress !== null;
255
    }
256
257
    /**
258
     * @return string|null
259
     */
260 276
    public function getStartAddress()
261
    {
262 276
        return $this->startAddress;
263
    }
264
265
    /**
266
     * @param string|null $startAddress
267
     */
268 8
    public function setStartAddress($startAddress = null)
269
    {
270 8
        $this->startAddress = $startAddress;
271 8
    }
272
273
    /**
274
     * @return bool
275
     */
276 12
    public function hasStartLocation()
277
    {
278 12
        return $this->startLocation !== null;
279
    }
280
281
    /**
282
     * @return Coordinate|null
283
     */
284 276
    public function getStartLocation()
285
    {
286 276
        return $this->startLocation;
287
    }
288
289
    /**
290
     * @param Coordinate|null $startLocation
291
     */
292 8
    public function setStartLocation(Coordinate $startLocation = null)
293
    {
294 8
        $this->startLocation = $startLocation;
295 8
    }
296
297
    /**
298
     * @return bool
299
     */
300 20
    public function hasSteps()
301
    {
302 20
        return !empty($this->steps);
303
    }
304
305
    /**
306
     * @return DirectionStep[]
307
     */
308 284
    public function getSteps()
309
    {
310 284
        return $this->steps;
311
    }
312
313
    /**
314
     * @param DirectionStep[] $steps
315
     */
316 8
    public function setSteps(array $steps)
317
    {
318 8
        $this->steps = [];
319 8
        $this->addSteps($steps);
320 8
    }
321
322
    /**
323
     * @param DirectionStep[] $steps
324
     */
325 8
    public function addSteps(array $steps)
326
    {
327 8
        foreach ($steps as $step) {
328 8
            $this->addStep($step);
329 4
        }
330 8
    }
331
332
    /**
333
     * @param DirectionStep $step
334
     *
335
     * @return bool
336
     */
337 16
    public function hasStep(DirectionStep $step)
338
    {
339 16
        return in_array($step, $this->steps, true);
340
    }
341
342
    /**
343
     * @param DirectionStep $step
344
     */
345 16
    public function addStep(DirectionStep $step)
346
    {
347 16
        if (!$this->hasStep($step)) {
348 16
            $this->steps[] = $step;
349 8
        }
350 16
    }
351
352
    /**
353
     * @param DirectionStep $step
354
     */
355 4
    public function removeStep(DirectionStep $step)
356
    {
357 4
        unset($this->steps[array_search($step, $this->steps, true)]);
358 4
        $this->steps = empty($this->steps) ? [] : array_values($this->steps);
359 4
    }
360
361
    /**
362
     * @return bool
363
     */
364 20
    public function hasViaWaypoints()
365
    {
366 20
        return !empty($this->viaWaypoints);
367
    }
368
369
    /**
370
     * @return DirectionWaypoint[]
371
     */
372 284
    public function getViaWaypoints()
373
    {
374 284
        return $this->viaWaypoints;
375
    }
376
377
    /**
378
     * @param DirectionWaypoint[] $viaWaypoints
379
     */
380 8
    public function setViaWaypoints(array $viaWaypoints)
381
    {
382 8
        $this->viaWaypoints = [];
383 8
        $this->addViaWaypoints($viaWaypoints);
384 8
    }
385
386
    /**
387
     * @param DirectionWaypoint[] $viaWaypoints
388
     */
389 8
    public function addViaWaypoints(array $viaWaypoints)
390
    {
391 8
        foreach ($viaWaypoints as $viaWaypoint) {
392 8
            $this->addViaWaypoint($viaWaypoint);
393 4
        }
394 8
    }
395
396
    /**
397
     * @param DirectionWaypoint $viaWaypoint
398
     *
399
     * @return bool
400
     */
401 16
    public function hasViaWaypoint(DirectionWaypoint $viaWaypoint)
402
    {
403 16
        return in_array($viaWaypoint, $this->viaWaypoints, true);
404
    }
405
406
    /**
407
     * @param DirectionWaypoint $viaWaypoint
408
     */
409 16
    public function addViaWaypoint(DirectionWaypoint $viaWaypoint)
410
    {
411 16
        if (!$this->hasViaWaypoint($viaWaypoint)) {
412 16
            $this->viaWaypoints[] = $viaWaypoint;
413 8
        }
414 16
    }
415
416
    /**
417
     * @param DirectionWaypoint $viaWaypoint
418
     */
419 4
    public function removeViaWaypoint(DirectionWaypoint $viaWaypoint)
420
    {
421 4
        unset($this->viaWaypoints[array_search($viaWaypoint, $this->viaWaypoints, true)]);
422 4
        $this->viaWaypoints = empty($this->viaWaypoints) ? [] : array_values($this->viaWaypoints);
423 4
    }
424
}
425