|
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 DirectionsTransitLine |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var string|null |
|
21
|
|
|
*/ |
|
22
|
|
|
private $name; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var string|null |
|
26
|
|
|
*/ |
|
27
|
|
|
private $shortName; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string|null |
|
31
|
|
|
*/ |
|
32
|
|
|
private $color; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var string|null |
|
36
|
|
|
*/ |
|
37
|
|
|
private $url; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var string|null |
|
41
|
|
|
*/ |
|
42
|
|
|
private $icon; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var string|null |
|
46
|
|
|
*/ |
|
47
|
|
|
private $textColor; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var DirectionsTransitVehicle|null |
|
51
|
|
|
*/ |
|
52
|
|
|
private $vehicle; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var DirectionsTransitAgency[] |
|
56
|
|
|
*/ |
|
57
|
|
|
private $agencies = []; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @return bool |
|
61
|
|
|
*/ |
|
62
|
|
|
public function hasName() |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->name !== null; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @return string|null |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getName() |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->name; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @param string|null $name |
|
77
|
|
|
*/ |
|
78
|
|
|
public function setName($name) |
|
79
|
|
|
{ |
|
80
|
|
|
$this->name = $name; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return bool |
|
85
|
|
|
*/ |
|
86
|
|
|
public function hasShortName() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->shortName !== null; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return string|null |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getShortName() |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->shortName; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @param string|null $shortName |
|
101
|
|
|
*/ |
|
102
|
|
|
public function setShortName($shortName) |
|
103
|
|
|
{ |
|
104
|
|
|
$this->shortName = $shortName; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @return bool |
|
109
|
|
|
*/ |
|
110
|
|
|
public function hasColor() |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->color !== null; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @return string|null |
|
117
|
|
|
*/ |
|
118
|
|
|
public function getColor() |
|
119
|
|
|
{ |
|
120
|
|
|
return $this->color; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @param string|null $color |
|
125
|
|
|
*/ |
|
126
|
|
|
public function setColor($color) |
|
127
|
|
|
{ |
|
128
|
|
|
$this->color = $color; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @return bool |
|
133
|
|
|
*/ |
|
134
|
|
|
public function hasUrl() |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->url !== null; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return string|null |
|
141
|
|
|
*/ |
|
142
|
|
|
public function getUrl() |
|
143
|
|
|
{ |
|
144
|
|
|
return $this->url; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* @param string|null $url |
|
149
|
|
|
*/ |
|
150
|
|
|
public function setUrl($url) |
|
151
|
|
|
{ |
|
152
|
|
|
$this->url = $url; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @return bool |
|
157
|
|
|
*/ |
|
158
|
|
|
public function hasIcon() |
|
159
|
|
|
{ |
|
160
|
|
|
return $this->icon !== null; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* @return string|null |
|
165
|
|
|
*/ |
|
166
|
|
|
public function getIcon() |
|
167
|
|
|
{ |
|
168
|
|
|
return $this->icon; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @param string|null $icon |
|
173
|
|
|
*/ |
|
174
|
|
|
public function setIcon($icon) |
|
175
|
|
|
{ |
|
176
|
|
|
$this->icon = $icon; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @return bool |
|
181
|
|
|
*/ |
|
182
|
|
|
public function hasTextColor() |
|
183
|
|
|
{ |
|
184
|
|
|
return $this->textColor !== null; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* @return string|null |
|
189
|
|
|
*/ |
|
190
|
|
|
public function getTextColor() |
|
191
|
|
|
{ |
|
192
|
|
|
return $this->textColor; |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
/** |
|
196
|
|
|
* @param string|null $textColor |
|
197
|
|
|
*/ |
|
198
|
|
|
public function setTextColor($textColor) |
|
199
|
|
|
{ |
|
200
|
|
|
$this->textColor = $textColor; |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* @return bool |
|
205
|
|
|
*/ |
|
206
|
|
|
public function hasVehicle() |
|
207
|
|
|
{ |
|
208
|
|
|
return $this->vehicle !== null; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* @return DirectionsTransitVehicle|null |
|
213
|
|
|
*/ |
|
214
|
|
|
public function getVehicle() |
|
215
|
|
|
{ |
|
216
|
|
|
return $this->vehicle; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* @param DirectionsTransitVehicle|null $vehicle |
|
221
|
|
|
*/ |
|
222
|
|
|
public function setVehicle(DirectionsTransitVehicle $vehicle = null) |
|
223
|
|
|
{ |
|
224
|
|
|
$this->vehicle = $vehicle; |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
/** |
|
228
|
|
|
* @return bool |
|
229
|
|
|
*/ |
|
230
|
|
|
public function hasAgencies() |
|
231
|
|
|
{ |
|
232
|
|
|
return !empty($this->agencies); |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
/** |
|
236
|
|
|
* @return DirectionsTransitAgency[] |
|
237
|
|
|
*/ |
|
238
|
|
|
public function getAgencies() |
|
239
|
|
|
{ |
|
240
|
|
|
return $this->agencies; |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
/** |
|
244
|
|
|
* @param DirectionsTransitAgency[] $agencies |
|
245
|
|
|
*/ |
|
246
|
|
|
public function setAgencies(array $agencies) |
|
247
|
|
|
{ |
|
248
|
|
|
$this->agencies = $agencies; |
|
249
|
|
|
$this->addAgencies($agencies); |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
/** |
|
253
|
|
|
* @param DirectionsTransitAgency[] $agencies |
|
254
|
|
|
*/ |
|
255
|
|
|
public function addAgencies(array $agencies) |
|
256
|
|
|
{ |
|
257
|
|
|
foreach ($agencies as $agency) { |
|
258
|
|
|
$this->addAgency($agency); |
|
259
|
|
|
} |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
/** |
|
263
|
|
|
* @param DirectionsTransitAgency $agency |
|
264
|
|
|
* |
|
265
|
|
|
* @return bool |
|
266
|
|
|
*/ |
|
267
|
|
|
public function hasAgency(DirectionsTransitAgency $agency) |
|
268
|
|
|
{ |
|
269
|
|
|
return in_array($agency, $this->agencies, true); |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* @param DirectionsTransitAgency $agency |
|
274
|
|
|
*/ |
|
275
|
|
|
public function addAgency(DirectionsTransitAgency $agency) |
|
276
|
|
|
{ |
|
277
|
|
|
if (!$this->hasAgency($agency)) { |
|
278
|
|
|
$this->agencies[] = $agency; |
|
279
|
|
|
} |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
/** |
|
283
|
|
|
* @param DirectionsTransitAgency $agency |
|
284
|
|
|
*/ |
|
285
|
|
|
public function removeAgency(DirectionsTransitAgency $agency) |
|
286
|
|
|
{ |
|
287
|
|
|
unset($this->agencies[array_search($agency, $this->agencies, true)]); |
|
288
|
|
|
$this->agencies = array_values($this->agencies); |
|
289
|
|
|
} |
|
290
|
|
|
} |
|
291
|
|
|
|