From 66832c41e9fff481c20ca219b3cc0a4e53b8b551 Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Wed, 25 Oct 2017 23:21:07 +0200 Subject: :arrow_up: Update intl library. Update intl library from v0.4? (2014) to v0.7.4 (2016). Use global composer autoloader now. --- vendor/commerceguys/intl/src/Country/Country.php | 168 +++++++++++++++++++++ .../intl/src/Country/CountryEntityInterface.php | 51 +++++++ .../intl/src/Country/CountryInterface.php | 61 ++++++++ .../intl/src/Country/CountryRepository.php | 143 ++++++++++++++++++ .../src/Country/CountryRepositoryInterface.php | 41 +++++ 5 files changed, 464 insertions(+) create mode 100644 vendor/commerceguys/intl/src/Country/Country.php create mode 100644 vendor/commerceguys/intl/src/Country/CountryEntityInterface.php create mode 100644 vendor/commerceguys/intl/src/Country/CountryInterface.php create mode 100644 vendor/commerceguys/intl/src/Country/CountryRepository.php create mode 100644 vendor/commerceguys/intl/src/Country/CountryRepositoryInterface.php (limited to 'vendor/commerceguys/intl/src/Country') diff --git a/vendor/commerceguys/intl/src/Country/Country.php b/vendor/commerceguys/intl/src/Country/Country.php new file mode 100644 index 000000000..7063e7d58 --- /dev/null +++ b/vendor/commerceguys/intl/src/Country/Country.php @@ -0,0 +1,168 @@ +getCountryCode(); + } + + /** + * {@inheritdoc} + */ + public function getCountryCode() + { + return $this->countryCode; + } + + /** + * {@inheritdoc} + */ + public function setCountryCode($countryCode) + { + $this->countryCode = $countryCode; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + /** + * {@inheritdoc} + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getThreeLetterCode() + { + return $this->threeLetterCode; + } + + /** + * {@inheritdoc} + */ + public function setThreeLetterCode($threeLetterCode) + { + $this->threeLetterCode = $threeLetterCode; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getNumericCode() + { + return $this->numericCode; + } + + /** + * {@inheritdoc} + */ + public function setNumericCode($numericCode) + { + $this->numericCode = $numericCode; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCurrencyCode() + { + return $this->currencyCode; + } + + /** + * {@inheritdoc} + */ + public function setCurrencyCode($currencyCode) + { + $this->currencyCode = $currencyCode; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getLocale() + { + return $this->locale; + } + + /** + * {@inheritdoc} + */ + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } +} diff --git a/vendor/commerceguys/intl/src/Country/CountryEntityInterface.php b/vendor/commerceguys/intl/src/Country/CountryEntityInterface.php new file mode 100644 index 000000000..b22bcd42f --- /dev/null +++ b/vendor/commerceguys/intl/src/Country/CountryEntityInterface.php @@ -0,0 +1,51 @@ +definitionPath = $definitionPath ? $definitionPath : __DIR__ . '/../../resources/country/'; + } + + /** + * {@inheritdoc} + */ + public function get($countryCode, $locale = null, $fallbackLocale = null) + { + $locale = $this->resolveLocale($locale, $fallbackLocale); + $definitions = $this->loadDefinitions($locale); + if (!isset($definitions[$countryCode])) { + throw new UnknownCountryException($countryCode); + } + + return $this->createCountryFromDefinition($countryCode, $definitions[$countryCode], $locale); + } + + /** + * {@inheritdoc} + */ + public function getAll($locale = null, $fallbackLocale = null) + { + $locale = $this->resolveLocale($locale, $fallbackLocale); + $definitions = $this->loadDefinitions($locale); + $countries = []; + foreach ($definitions as $countryCode => $definition) { + $countries[$countryCode] = $this->createCountryFromDefinition($countryCode, $definition, $locale); + } + + return $countries; + } + + /** + * {@inheritdoc} + */ + public function getList($locale = null, $fallbackLocale = null) + { + $locale = $this->resolveLocale($locale, $fallbackLocale); + $definitions = $this->loadDefinitions($locale); + $list = []; + foreach ($definitions as $countryCode => $definition) { + $list[$countryCode] = $definition['name']; + } + + return $list; + } + + /** + * Loads the country definitions for the provided locale. + * + * @param string $locale The desired locale. + * + * @return array + */ + protected function loadDefinitions($locale) + { + if (!isset($this->definitions[$locale])) { + $filename = $this->definitionPath . $locale . '.json'; + $this->definitions[$locale] = json_decode(file_get_contents($filename), true); + + // Make sure the base definitions have been loaded. + if (empty($this->baseDefinitions)) { + $this->baseDefinitions = json_decode(file_get_contents($this->definitionPath . 'base.json'), true); + } + // Merge-in base definitions. + foreach ($this->definitions[$locale] as $countryCode => $definition) { + $this->definitions[$locale][$countryCode] += $this->baseDefinitions[$countryCode]; + } + } + + return $this->definitions[$locale]; + } + + /** + * Creates a country object from the provided definition. + * + * @param string $countryCode The country code. + * @param array $definition The country definition. + * @param string $locale The locale of the country definition. + * + * @return Country + */ + protected function createCountryFromDefinition($countryCode, array $definition, $locale) + { + $country = new Country(); + $setValues = \Closure::bind(function ($countryCode, $definition, $locale) { + $this->countryCode = $countryCode; + $this->name = $definition['name']; + $this->locale = $locale; + if (isset($definition['three_letter_code'])) { + $this->threeLetterCode = $definition['three_letter_code']; + } + if (isset($definition['numeric_code'])) { + $this->numericCode = $definition['numeric_code']; + } + if (isset($definition['currency_code'])) { + $this->currencyCode = $definition['currency_code']; + } + }, $country, '\CommerceGuys\Intl\Country\Country'); + $setValues($countryCode, $definition, $locale); + + return $country; + } +} diff --git a/vendor/commerceguys/intl/src/Country/CountryRepositoryInterface.php b/vendor/commerceguys/intl/src/Country/CountryRepositoryInterface.php new file mode 100644 index 000000000..fbcd5551e --- /dev/null +++ b/vendor/commerceguys/intl/src/Country/CountryRepositoryInterface.php @@ -0,0 +1,41 @@ +