|
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\Geocoder; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderAddressComponent |
|
16
|
|
|
* |
|
17
|
|
|
* @author GeLo <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
class GeocoderAddress |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @var string|null |
|
23
|
|
|
*/ |
|
24
|
|
|
private $longName; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var string|null |
|
28
|
|
|
*/ |
|
29
|
|
|
private $shortName; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var string[] |
|
33
|
|
|
*/ |
|
34
|
|
|
private $types = []; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @return bool |
|
38
|
|
|
*/ |
|
39
|
|
|
public function hasLongName() |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->longName !== null; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return string|null |
|
46
|
|
|
*/ |
|
47
|
|
|
public function getLongName() |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->longName; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param string|null $longName |
|
54
|
|
|
*/ |
|
55
|
|
|
public function setLongName($longName = null) |
|
56
|
|
|
{ |
|
57
|
|
|
$this->longName = $longName; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return bool |
|
62
|
|
|
*/ |
|
63
|
|
|
public function hasShortName() |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->shortName !== null; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return string|null |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getShortName() |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->shortName; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @param string|null $shortName |
|
78
|
|
|
*/ |
|
79
|
|
|
public function setShortName($shortName = null) |
|
80
|
|
|
{ |
|
81
|
|
|
$this->shortName = $shortName; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return bool |
|
86
|
|
|
*/ |
|
87
|
|
|
public function hasTypes() |
|
88
|
|
|
{ |
|
89
|
|
|
return !empty($this->types); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return string[] |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getTypes() |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->types; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @param string[] $types |
|
102
|
|
|
*/ |
|
103
|
|
|
public function setTypes(array $types) |
|
104
|
|
|
{ |
|
105
|
|
|
$this->types = []; |
|
106
|
|
|
$this->addTypes($types); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @param string[] $types |
|
111
|
|
|
*/ |
|
112
|
|
|
public function addTypes(array $types) |
|
113
|
|
|
{ |
|
114
|
|
|
foreach ($types as $type) { |
|
115
|
|
|
$this->addType($type); |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @param string $type |
|
121
|
|
|
* |
|
122
|
|
|
* @return bool |
|
123
|
|
|
*/ |
|
124
|
|
|
public function hasType($type) |
|
125
|
|
|
{ |
|
126
|
|
|
return in_array($type, $this->types, true); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* @param string $type |
|
131
|
|
|
*/ |
|
132
|
|
|
public function addType($type) |
|
133
|
|
|
{ |
|
134
|
|
|
if (!$this->hasType($type)) { |
|
135
|
|
|
$this->types[] = $type; |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @param string $type |
|
141
|
|
|
*/ |
|
142
|
|
|
public function removeType($type) |
|
143
|
|
|
{ |
|
144
|
|
|
unset($this->types[array_search($type, $this->types, true)]); |
|
145
|
|
|
$this->types = array_values($this->types); |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|