|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace talismanfr\geocode\entity; |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use yii\helpers\ArrayHelper; |
|
8
|
|
|
|
|
9
|
|
|
final class AddressDetails |
|
10
|
|
|
{ |
|
11
|
|
|
private $addressLine; |
|
12
|
|
|
|
|
13
|
|
|
private $countryNameCode; |
|
14
|
|
|
|
|
15
|
|
|
private $countryName; |
|
16
|
|
|
|
|
17
|
|
|
private $administrativeAreaName; |
|
18
|
|
|
|
|
19
|
|
|
private $subAdministrativeAreaName; |
|
20
|
|
|
|
|
21
|
|
|
private $localiteName; |
|
22
|
|
|
|
|
23
|
|
|
private $thoroughfareName; |
|
24
|
|
|
|
|
25
|
|
|
private $premiseNumber; |
|
26
|
|
|
|
|
27
|
|
|
private $postalCodeNumber; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* AddressDetails constructor. |
|
31
|
|
|
* @param $addressLine |
|
32
|
|
|
* @param $countryNameCode |
|
33
|
|
|
* @param $countryName |
|
34
|
|
|
* @param $administrativeAreaName |
|
35
|
|
|
* @param $subAdministrativeAreaName |
|
36
|
|
|
* @param $localiteName |
|
37
|
|
|
* @param $thoroughfareName |
|
38
|
|
|
* @param $premiseNumber |
|
39
|
|
|
* @param $postalCodeNumber |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct($addressLine, $countryNameCode, $countryName, $administrativeAreaName, $subAdministrativeAreaName, $localiteName, $thoroughfareName, $premiseNumber, $postalCodeNumber) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->addressLine = $addressLine; |
|
44
|
|
|
$this->countryNameCode = $countryNameCode; |
|
45
|
|
|
$this->countryName = $countryName; |
|
46
|
|
|
$this->administrativeAreaName = $administrativeAreaName; |
|
47
|
|
|
$this->subAdministrativeAreaName = $subAdministrativeAreaName; |
|
48
|
|
|
$this->localiteName = $localiteName; |
|
49
|
|
|
$this->thoroughfareName = $thoroughfareName; |
|
50
|
|
|
$this->premiseNumber = $premiseNumber; |
|
51
|
|
|
$this->postalCodeNumber = $postalCodeNumber; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param array $state |
|
56
|
|
|
* @return AddressDetails |
|
57
|
|
|
*/ |
|
58
|
|
|
public static function fromState(array $state): self |
|
59
|
|
|
{ |
|
60
|
|
|
$addressLine=ArrayHelper::getValue($state,'Country.AddressLine'); |
|
61
|
|
|
$countryNameCode=ArrayHelper::getValue($state,'Country.CountryNameCode'); |
|
62
|
|
|
$countryName=ArrayHelper::getValue($state,'Country.CountryName'); |
|
63
|
|
|
$administrativeAreaName=ArrayHelper::getValue($state,'Country.AdministrativeArea.AdministrativeAreaName'); |
|
64
|
|
|
$subAdministrariveAreaName=ArrayHelper::getValue($state,'Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName'); |
|
65
|
|
|
$subAdm=ArrayHelper::getValue($state,'Country.AdministrativeArea.SubAdministrativeArea'); |
|
66
|
|
|
$locality=ArrayHelper::getValue($subAdm,'Locality.LocalityName'); |
|
67
|
|
|
$throughfareName=ArrayHelper::getValue($subAdm,'Locality.Thoroughfare.ThoroughfareName'); |
|
68
|
|
|
$premiseNumber=ArrayHelper::getValue($subAdm,'Locality.Thoroughfare.Premise.PremiseNumber'); |
|
69
|
|
|
$postalCodeNumber=ArrayHelper::getValue($subAdm,'Locality.Thoroughfare.Premise.PostalCode.PostalCodeNumber'); |
|
70
|
|
|
|
|
71
|
|
|
return new self($addressLine,$countryNameCode,$countryName,$administrativeAreaName, |
|
72
|
|
|
$subAdministrariveAreaName,$locality,$throughfareName,$premiseNumber,$postalCodeNumber); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return mixed |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getAddressLine() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->addressLine; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return mixed |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getCountryNameCode() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->countryNameCode; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return mixed |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getCountryName() |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->countryName; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @return mixed |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getAdministrativeAreaName() |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->administrativeAreaName; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @return mixed |
|
109
|
|
|
*/ |
|
110
|
|
|
public function getSubAdministrativeAreaName() |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->subAdministrativeAreaName; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @return mixed |
|
117
|
|
|
*/ |
|
118
|
|
|
public function getLocaliteName() |
|
119
|
|
|
{ |
|
120
|
|
|
return $this->localiteName; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @return mixed |
|
125
|
|
|
*/ |
|
126
|
|
|
public function getThoroughfareName() |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->thoroughfareName; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @return mixed |
|
133
|
|
|
*/ |
|
134
|
|
|
public function getPremiseNumber() |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->premiseNumber; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return mixed |
|
141
|
|
|
*/ |
|
142
|
|
|
public function getPostalCodeNumber() |
|
143
|
|
|
{ |
|
144
|
|
|
return $this->postalCodeNumber; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
|
|
148
|
|
|
|
|
149
|
|
|
|
|
150
|
|
|
} |