CurrencyDataProvider.php
3 months ago
DateTimeFormatProvider.php
6 months ago
LanguageDataProvider.php
2 years ago
RegionDataProvider.php
1 year ago
RegionDataProvider.php
53 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Matomo - free/libre analytics platform |
| 5 | * |
| 6 | * @link https://matomo.org |
| 7 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 8 | */ |
| 9 | namespace Piwik\Intl\Data\Provider; |
| 10 | |
| 11 | /** |
| 12 | * Provides region related data (continents, countries, etc.). |
| 13 | */ |
| 14 | class RegionDataProvider |
| 15 | { |
| 16 | private $continentList; |
| 17 | private $countryList; |
| 18 | private $countryExtraList; |
| 19 | /** |
| 20 | * Returns the list of continent codes. |
| 21 | * |
| 22 | * @return string[] Array of 3 letter continent codes |
| 23 | * @api |
| 24 | */ |
| 25 | public function getContinentList() |
| 26 | { |
| 27 | if ($this->continentList === null) { |
| 28 | $this->continentList = (require __DIR__ . '/../Resources/continents.php'); |
| 29 | } |
| 30 | return $this->continentList; |
| 31 | } |
| 32 | /** |
| 33 | * Returns the list of valid country codes. |
| 34 | * |
| 35 | * @param bool $includeInternalCodes |
| 36 | * @return string[] Array of 2 letter country ISO codes => 3 letter continent code |
| 37 | * @api |
| 38 | */ |
| 39 | public function getCountryList($includeInternalCodes = \false) |
| 40 | { |
| 41 | if ($this->countryList === null) { |
| 42 | $this->countryList = (require __DIR__ . '/../Resources/countries.php'); |
| 43 | } |
| 44 | if ($this->countryExtraList === null) { |
| 45 | $this->countryExtraList = (require __DIR__ . '/../Resources/countries-extra.php'); |
| 46 | } |
| 47 | if ($includeInternalCodes) { |
| 48 | return array_merge($this->countryList, $this->countryExtraList); |
| 49 | } |
| 50 | return $this->countryList; |
| 51 | } |
| 52 | } |
| 53 |