1 | <?php |
||
26 | class CountrySubRegionDao |
||
27 | { |
||
28 | |||
29 | const REPO_URL = 'https://raw.githubusercontent.com/eventespresso/countries-and-subregions/master/'; |
||
30 | |||
31 | const OPTION_NAME_COUNTRY_DATA_VERSION = 'espresso-country-sub-region-data-version'; |
||
32 | |||
33 | /** |
||
34 | * @var EEM_State $state_model |
||
35 | */ |
||
36 | private $state_model; |
||
37 | |||
38 | /** |
||
39 | * @var JsonValidator $json_validator |
||
40 | */ |
||
41 | private $json_validator; |
||
42 | |||
43 | /** |
||
44 | * @var string $data_version |
||
45 | */ |
||
46 | private $data_version; |
||
47 | |||
48 | /** |
||
49 | * @var array $countries |
||
50 | */ |
||
51 | private $countries = array(); |
||
52 | |||
53 | |||
54 | /** |
||
55 | * CountrySubRegionDao constructor. |
||
56 | * |
||
57 | * @param EEM_State $state_model |
||
58 | * @param JsonValidator $json_validator |
||
59 | */ |
||
60 | public function __construct(EEM_State $state_model, JsonValidator $json_validator) |
||
65 | |||
66 | |||
67 | /** |
||
68 | * @param EE_Country $country_object |
||
69 | * @return bool |
||
70 | * @throws EE_Error |
||
71 | * @throws InvalidArgumentException |
||
72 | * @throws InvalidDataTypeException |
||
73 | * @throws InvalidInterfaceException |
||
74 | * @throws ReflectionException |
||
75 | */ |
||
76 | public function saveCountrySubRegions(EE_Country $country_object) |
||
106 | |||
107 | |||
108 | /** |
||
109 | * @since 4.9.70.p |
||
110 | * @return string |
||
111 | */ |
||
112 | private function getCountrySubRegionDataVersion() |
||
116 | |||
117 | |||
118 | /** |
||
119 | * @param string $version |
||
120 | */ |
||
121 | private function updateCountrySubRegionDataVersion($version = '') |
||
130 | |||
131 | |||
132 | /** |
||
133 | * @param string $CNT_ISO |
||
134 | * @param array $countries |
||
135 | * @return int |
||
136 | * @throws EE_Error |
||
137 | * @throws InvalidArgumentException |
||
138 | * @throws InvalidDataTypeException |
||
139 | * @throws InvalidInterfaceException |
||
140 | * @throws ReflectionException |
||
141 | * @since 4.9.70.p |
||
142 | */ |
||
143 | private function processCountryData($CNT_ISO, $countries = array()) |
||
161 | |||
162 | |||
163 | /** |
||
164 | * @param string $url |
||
165 | * @return array |
||
166 | */ |
||
167 | private function retrieveJsonData($url) |
||
195 | |||
196 | |||
197 | /** |
||
198 | * @param stdClass $country |
||
199 | * @param array $sub_regions |
||
200 | * @return int |
||
201 | * @throws EE_Error |
||
202 | * @throws InvalidArgumentException |
||
203 | * @throws InvalidDataTypeException |
||
204 | * @throws InvalidInterfaceException |
||
205 | * @throws ReflectionException |
||
206 | */ |
||
207 | private function saveSubRegionData(stdClass $country, $sub_regions = array()) |
||
240 | |||
241 | |||
242 | /** |
||
243 | * @param string $CNT_ISO |
||
244 | * @since $VID:$ |
||
245 | * @return array |
||
246 | * @throws EE_Error |
||
247 | * @throws InvalidArgumentException |
||
248 | * @throws InvalidDataTypeException |
||
249 | * @throws InvalidInterfaceException |
||
250 | * @throws ReflectionException |
||
251 | */ |
||
252 | private function getExistingStateAbbreviations($CNT_ISO) |
||
273 | } |
||
274 |