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.
Completed
Push — services ( fe049d )
by Eric
03:30
created

DirectionsResponse::setRoutes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
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\Directions\Response;
13
14
/**
15
 * @author GeLo <[email protected]>
16
 */
17
class DirectionsResponse
18
{
19
    /**
20
     * @var string|null
21
     */
22
    private $status;
23
24
    /**
25
     * @var DirectionsRoute[]
26
     */
27
    private $routes = [];
28
29
    /**
30
     * @var DirectionsGeocoded[]
31
     */
32
    private $geocodedWaypoints = [];
33
34
    /**
35
     * @var string[]
36
     */
37
    private $availableTravelModes = [];
38
39
    /**
40
     * @return bool
41
     */
42
    public function hasStatus()
43
    {
44
        return $this->status !== null;
45
    }
46
47
    /**
48
     * @return string|null
49
     */
50
    public function getStatus()
51
    {
52
        return $this->status;
53
    }
54
55
    /**
56
     * @param string|null $status
57
     */
58
    public function setStatus($status = null)
59
    {
60
        $this->status = $status;
61
    }
62
63
    /**
64
     * @return bool
65
     */
66
    public function hasRoutes()
67
    {
68
        return !empty($this->routes);
69
    }
70
71
    /**
72
     * @return DirectionsRoute[]
73
     */
74
    public function getRoutes()
75
    {
76
        return $this->routes;
77
    }
78
79
    /**
80
     * @param DirectionsRoute[] $routes
81
     */
82
    public function setRoutes(array $routes)
83
    {
84
        $this->routes = [];
85
        $this->addRoutes($routes);
86
    }
87
88
    /**
89
     * @param DirectionsRoute[] $routes
90
     */
91
    public function addRoutes(array $routes)
92
    {
93
        foreach ($routes as $route) {
94
            $this->addRoute($route);
95
        }
96
    }
97
98
    /**
99
     * @param DirectionsRoute $route
100
     *
101
     * @return bool
102
     */
103
    public function hasRoute(DirectionsRoute $route)
104
    {
105
        return in_array($route, $this->routes, true);
106
    }
107
108
    /**
109
     * @param DirectionsRoute $route
110
     */
111
    public function addRoute(DirectionsRoute $route)
112
    {
113
        if (!$this->hasRoute($route)) {
114
            $this->routes[] = $route;
115
        }
116
    }
117
118
    /**
119
     * @param DirectionsRoute $route
120
     */
121
    public function removeRoute(DirectionsRoute $route)
122
    {
123
        unset($this->routes[array_search($route, $this->routes, true)]);
124
        $this->routes = array_values($this->routes);
125
    }
126
127
    /**
128
     * @return bool
129
     */
130
    public function hasGeocodedWaypoints()
131
    {
132
        return !empty($this->geocodedWaypoints);
133
    }
134
135
    /**
136
     * @return DirectionsGeocoded[]
137
     */
138
    public function getGeocodedWaypoints()
139
    {
140
        return $this->geocodedWaypoints;
141
    }
142
143
    /**
144
     * @param DirectionsGeocoded[] $geocodedWaypoints
145
     */
146
    public function setGeocodedWaypoints(array $geocodedWaypoints)
147
    {
148
        $this->geocodedWaypoints = [];
149
        $this->addGeocodedWaypoints($geocodedWaypoints);
150
    }
151
152
    /**
153
     * @param DirectionsGeocoded[] $geocodedWaypoints
154
     */
155
    public function addGeocodedWaypoints(array $geocodedWaypoints)
156
    {
157
        foreach ($geocodedWaypoints as $geocodedWaypoint) {
158
            $this->addGeocodedWaypoint($geocodedWaypoint);
159
        }
160
    }
161
162
    /**
163
     * @param DirectionsGeocoded $geocodedWaypoint
164
     *
165
     * @return bool
166
     */
167
    public function hasGeocodedWaypoint(DirectionsGeocoded $geocodedWaypoint)
168
    {
169
        return in_array($geocodedWaypoint, $this->geocodedWaypoints, true);
170
    }
171
172
    /**
173
     * @param DirectionsGeocoded $geocodedWaypoint
174
     */
175
    public function addGeocodedWaypoint(DirectionsGeocoded $geocodedWaypoint)
176
    {
177
        if (!$this->hasGeocodedWaypoint($geocodedWaypoint)) {
178
            $this->geocodedWaypoints[] = $geocodedWaypoint;
179
        }
180
    }
181
182
    /**
183
     * @param DirectionsGeocoded $geocodedWaypoint
184
     */
185
    public function removeGeocodedWaypoint(DirectionsGeocoded $geocodedWaypoint)
186
    {
187
        unset($this->geocodedWaypoints[array_search($geocodedWaypoint, $this->geocodedWaypoints, true)]);
188
        $this->geocodedWaypoints = array_values($this->geocodedWaypoints);
189
    }
190
191
    /**
192
     * @return bool
193
     */
194
    public function hasAvailableTravelModes()
195
    {
196
        return !empty($this->availableTravelModes);
197
    }
198
199
    /**
200
     * @return string[]
201
     */
202
    public function getAvailableTravelModes()
203
    {
204
        return $this->availableTravelModes;
205
    }
206
207
    /**
208
     * @param string[] $availableTravelModes
209
     */
210
    public function setAvailableTravelModes(array $availableTravelModes)
211
    {
212
        $this->availableTravelModes = [];
213
        $this->addAvailableTravelModes($availableTravelModes);
214
    }
215
216
    /**
217
     * @param string[] $availableTravelModes
218
     */
219
    public function addAvailableTravelModes(array $availableTravelModes)
220
    {
221
        foreach ($availableTravelModes as $availableTravelMode) {
222
            $this->addAvailableTravelMode($availableTravelMode);
223
        }
224
    }
225
226
    /**
227
     * @param string $availableTravelMode
228
     *
229
     * @return bool
230
     */
231
    public function hasAvailableTravelMode($availableTravelMode)
232
    {
233
        return in_array($availableTravelMode, $this->availableTravelModes, true);
234
    }
235
236
    /**
237
     * @param string $availableTravelMode
238
     */
239
    public function addAvailableTravelMode($availableTravelMode)
240
    {
241
        if (!$this->hasAvailableTravelMode($availableTravelMode)) {
242
            $this->availableTravelModes[] = $availableTravelMode;
243
        }
244
    }
245
246
    /**
247
     * @param string $availableTravelMode
248
     */
249
    public function removeAvailableTravelMode($availableTravelMode)
250
    {
251
        unset($this->availableTravelModes[array_search($availableTravelMode, $this->availableTravelModes, true)]);
252
        $this->availableTravelModes = array_values($this->availableTravelModes);
253
    }
254
}
255