1 | <?php |
||
24 | class CountrySubRegionDao |
||
25 | { |
||
26 | |||
27 | const REPO_URL = 'https://raw.githubusercontent.com/eventespresso/countries-and-subregions/master/'; |
||
28 | |||
29 | const OPTION_NAME_COUNTRY_DATA_VERSION = 'espresso-country-sub-region-data-version'; |
||
30 | |||
31 | /** |
||
32 | * @var EEM_State $state_model |
||
33 | */ |
||
34 | private $state_model; |
||
35 | |||
36 | /** |
||
37 | * @var JsonValidator $json_validator |
||
38 | */ |
||
39 | private $json_validator; |
||
40 | |||
41 | /** |
||
42 | * @var string $data_version |
||
43 | */ |
||
44 | private $data_version; |
||
45 | |||
46 | /** |
||
47 | * @var array $countries |
||
48 | */ |
||
49 | private $countries = array(); |
||
50 | |||
51 | |||
52 | /** |
||
53 | * CountrySubRegionDao constructor. |
||
54 | * |
||
55 | * @param EEM_State $state_model |
||
56 | * @param JsonValidator $json_validator |
||
57 | */ |
||
58 | public function __construct(EEM_State $state_model, JsonValidator $json_validator) |
||
63 | |||
64 | |||
65 | /** |
||
66 | * @param EE_Country $country_object |
||
67 | * @return void |
||
68 | * @throws EE_Error |
||
69 | * @throws InvalidArgumentException |
||
70 | * @throws InvalidDataTypeException |
||
71 | * @throws InvalidInterfaceException |
||
72 | * @throws ReflectionException |
||
73 | */ |
||
74 | public function saveCountrySubRegions(EE_Country $country_object) |
||
102 | |||
103 | |||
104 | /** |
||
105 | * @since 4.9.70.p |
||
106 | * @return string |
||
107 | */ |
||
108 | private function getCountrySubRegionDataVersion() |
||
112 | |||
113 | |||
114 | /** |
||
115 | * @param string $version |
||
116 | */ |
||
117 | private function updateCountrySubRegionDataVersion($version = '') |
||
126 | |||
127 | |||
128 | /** |
||
129 | * @param string $CNT_ISO |
||
130 | * @param array $countries |
||
131 | * @since 4.9.70.p |
||
132 | * @return int |
||
133 | * @throws EE_Error |
||
134 | * @throws InvalidArgumentException |
||
135 | * @throws InvalidDataTypeException |
||
136 | * @throws InvalidInterfaceException |
||
137 | */ |
||
138 | private function processCountryData($CNT_ISO, $countries = array()) |
||
156 | |||
157 | |||
158 | /** |
||
159 | * @param string $url |
||
160 | * @return array |
||
161 | */ |
||
162 | private function retrieveJsonData($url) |
||
190 | |||
191 | |||
192 | /** |
||
193 | * @param stdClass $country |
||
194 | * @param array $sub_regions |
||
195 | * @return int |
||
196 | * @throws EE_Error |
||
197 | * @throws InvalidArgumentException |
||
198 | * @throws InvalidDataTypeException |
||
199 | * @throws InvalidInterfaceException |
||
200 | */ |
||
201 | private function saveSubRegionData(stdClass $country, $sub_regions = array()) |
||
231 | } |
||
232 |