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 — directions-geocoded-waypoints ( 1f85e3 )
by Eric
02:24
created

DirectionsResponse::addGeocodedWaypoints()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
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;
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
     * @return bool
36
     */
37
    public function hasStatus()
38
    {
39
        return $this->status !== null;
40
    }
41
42
    /**
43
     * @return string|null
44
     */
45
    public function getStatus()
46
    {
47
        return $this->status;
48
    }
49
50
    /**
51
     * @param string|null $status
52
     */
53
    public function setStatus($status = null)
54
    {
55
        $this->status = $status;
56
    }
57
58
    /**
59
     * @return bool
60
     */
61
    public function hasRoutes()
62
    {
63
        return !empty($this->routes);
64
    }
65
66
    /**
67
     * @return DirectionsRoute[]
68
     */
69
    public function getRoutes()
70
    {
71
        return $this->routes;
72
    }
73
74
    /**
75
     * @param DirectionsRoute[] $routes
76
     */
77
    public function setRoutes(array $routes)
78
    {
79
        $this->routes = [];
80
        $this->addRoutes($routes);
81
    }
82
83
    /**
84
     * @param DirectionsRoute[] $routes
85
     */
86
    public function addRoutes(array $routes)
87
    {
88
        foreach ($routes as $route) {
89
            $this->addRoute($route);
90
        }
91
    }
92
93
    /**
94
     * @param DirectionsRoute $route
95
     *
96
     * @return bool
97
     */
98
    public function hasRoute(DirectionsRoute $route)
99
    {
100
        return in_array($route, $this->routes, true);
101
    }
102
103
    /**
104
     * @param DirectionsRoute $route
105
     */
106
    public function addRoute(DirectionsRoute $route)
107
    {
108
        if (!$this->hasRoute($route)) {
109
            $this->routes[] = $route;
110
        }
111
    }
112
113
    /**
114
     * @param DirectionsRoute $route
115
     */
116
    public function removeRoute(DirectionsRoute $route)
117
    {
118
        unset($this->routes[array_search($route, $this->routes, true)]);
119
        $this->routes = array_values($this->routes);
120
    }
121
122
    /**
123
     * @return bool
124
     */
125
    public function hasGeocodedWaypoints()
126
    {
127
        return !empty($this->geocodedWaypoints);
128
    }
129
130
    /**
131
     * @return DirectionsGeocoded[]
132
     */
133
    public function getGeocodedWaypoints()
134
    {
135
        return $this->geocodedWaypoints;
136
    }
137
138
    /**
139
     * @param DirectionsGeocoded[] $geocodedWaypoints
140
     */
141
    public function setGeocodedWaypoints(array $geocodedWaypoints)
142
    {
143
        $this->geocodedWaypoints = [];
144
        $this->addGeocodedWaypoints($geocodedWaypoints);
145
    }
146
147
    /**
148
     * @param DirectionsGeocoded[] $geocodedWaypoints
149
     */
150
    public function addGeocodedWaypoints(array $geocodedWaypoints)
151
    {
152
        foreach ($geocodedWaypoints as $geocodedWaypoint) {
153
            $this->addGeocodedWaypoint($geocodedWaypoint);
154
        }
155
    }
156
157
    /**
158
     * @param DirectionsGeocoded $geocodedWaypoint
159
     *
160
     * @return bool
161
     */
162
    public function hasGeocodedWaypoint(DirectionsGeocoded $geocodedWaypoint)
163
    {
164
        return in_array($geocodedWaypoint, $this->geocodedWaypoints, true);
165
    }
166
167
    /**
168
     * @param DirectionsGeocoded $geocodedWaypoint
169
     */
170
    public function addGeocodedWaypoint(DirectionsGeocoded $geocodedWaypoint)
171
    {
172
        if (!$this->hasGeocodedWaypoint($geocodedWaypoint)) {
173
            $this->geocodedWaypoints[] = $geocodedWaypoint;
174
        }
175
    }
176
177
    /**
178
     * @param DirectionsGeocoded $geocodedWaypoint
179
     */
180
    public function removeGeocodedWaypoint(DirectionsGeocoded $geocodedWaypoint)
181
    {
182
        unset($this->geocodedWaypoints[array_search($geocodedWaypoint, $this->geocodedWaypoints, true)]);
183
        $this->geocodedWaypoints = array_values($this->geocodedWaypoints);
184
    }
185
}
186