aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/commerceguys/intl/src/NumberFormat
diff options
context:
space:
mode:
authorKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2017-10-25 23:21:07 +0200
committerKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2017-10-29 22:00:12 +0100
commit66832c41e9fff481c20ca219b3cc0a4e53b8b551 (patch)
treeffff0bb391350ec9c8c16bcf8781bce6d866cf89 /vendor/commerceguys/intl/src/NumberFormat
parent8e4c5db766ce23d05b8507991b04fece743147de (diff)
downloadvolse-hubzilla-66832c41e9fff481c20ca219b3cc0a4e53b8b551.tar.gz
volse-hubzilla-66832c41e9fff481c20ca219b3cc0a4e53b8b551.tar.bz2
volse-hubzilla-66832c41e9fff481c20ca219b3cc0a4e53b8b551.zip
:arrow_up: Update intl library.
Update intl library from v0.4? (2014) to v0.7.4 (2016). Use global composer autoloader now.
Diffstat (limited to 'vendor/commerceguys/intl/src/NumberFormat')
-rw-r--r--vendor/commerceguys/intl/src/NumberFormat/NumberFormat.php269
-rw-r--r--vendor/commerceguys/intl/src/NumberFormat/NumberFormatEntityInterface.php107
-rw-r--r--vendor/commerceguys/intl/src/NumberFormat/NumberFormatInterface.php106
-rw-r--r--vendor/commerceguys/intl/src/NumberFormat/NumberFormatRepository.php91
-rw-r--r--vendor/commerceguys/intl/src/NumberFormat/NumberFormatRepositoryInterface.php19
5 files changed, 592 insertions, 0 deletions
diff --git a/vendor/commerceguys/intl/src/NumberFormat/NumberFormat.php b/vendor/commerceguys/intl/src/NumberFormat/NumberFormat.php
new file mode 100644
index 000000000..077f6721f
--- /dev/null
+++ b/vendor/commerceguys/intl/src/NumberFormat/NumberFormat.php
@@ -0,0 +1,269 @@
+<?php
+
+namespace CommerceGuys\Intl\NumberFormat;
+
+class NumberFormat implements NumberFormatEntityInterface
+{
+ /**
+ * The locale (i.e. "en_US").
+ *
+ * @var string
+ */
+ protected $locale;
+
+ /**
+ * The numbering system.
+ *
+ * @var string
+ */
+ protected $numberingSystem = [];
+
+ /**
+ * The decimal separator.
+ *
+ * @var string
+ */
+ protected $decimalSeparator = [];
+
+ /**
+ * The grouping separator.
+ *
+ * @var string
+ */
+ protected $groupingSeparator = [];
+
+ /**
+ * The plus sign.
+ *
+ * @var string
+ */
+ protected $plusSign = [];
+
+ /**
+ * The number symbols.
+ *
+ * @var string
+ */
+ protected $minusSign = [];
+
+ /**
+ * The percent sign.
+ *
+ * @var string
+ */
+ protected $percentSign = [];
+
+ /**
+ * The number pattern used to format decimal numbers.
+ *
+ * @var string
+ */
+ protected $decimalPattern;
+
+ /**
+ * The number pattern used to format percentages.
+ *
+ * @var string
+ */
+ protected $percentPattern;
+
+ /**
+ * The number pattern used to format currency amounts.
+ *
+ * @var string
+ */
+ protected $currencyPattern;
+
+ /**
+ * The number pattern used to format accounting currency amounts.
+ *
+ * @var string
+ */
+ protected $accountingCurrencyPattern;
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getLocale()
+ {
+ return $this->locale;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setLocale($locale)
+ {
+ $this->locale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getNumberingSystem()
+ {
+ return $this->numberingSystem;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setNumberingSystem($numberingSystem)
+ {
+ $this->numberingSystem = $numberingSystem;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getDecimalSeparator()
+ {
+ return $this->decimalSeparator;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setDecimalSeparator($decimalSeparator)
+ {
+ $this->decimalSeparator = $decimalSeparator;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getGroupingSeparator()
+ {
+ return $this->groupingSeparator;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setGroupingSeparator($groupingSeparator)
+ {
+ $this->groupingSeparator = $groupingSeparator;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPlusSign()
+ {
+ return $this->plusSign;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setPlusSign($plusSign)
+ {
+ $this->plusSign = $plusSign;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getMinusSign()
+ {
+ return $this->minusSign;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setMinusSign($minusSign)
+ {
+ $this->minusSign = $minusSign;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPercentSign()
+ {
+ return $this->percentSign;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setPercentSign($percentSign)
+ {
+ $this->percentSign = $percentSign;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getDecimalPattern()
+ {
+ return $this->decimalPattern;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setDecimalPattern($decimalPattern)
+ {
+ $this->decimalPattern = $decimalPattern;
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPercentPattern()
+ {
+ return $this->percentPattern;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setPercentPattern($percentPattern)
+ {
+ $this->percentPattern = $percentPattern;
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getCurrencyPattern()
+ {
+ return $this->currencyPattern;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setCurrencyPattern($currencyPattern)
+ {
+ $this->currencyPattern = $currencyPattern;
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccountingCurrencyPattern()
+ {
+ return $this->accountingCurrencyPattern;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setAccountingCurrencyPattern($accountingCurrencyPattern)
+ {
+ $this->accountingCurrencyPattern = $accountingCurrencyPattern;
+
+ return $this;
+ }
+}
diff --git a/vendor/commerceguys/intl/src/NumberFormat/NumberFormatEntityInterface.php b/vendor/commerceguys/intl/src/NumberFormat/NumberFormatEntityInterface.php
new file mode 100644
index 000000000..debafd6ba
--- /dev/null
+++ b/vendor/commerceguys/intl/src/NumberFormat/NumberFormatEntityInterface.php
@@ -0,0 +1,107 @@
+<?php
+
+namespace CommerceGuys\Intl\NumberFormat;
+
+interface NumberFormatEntityInterface extends NumberFormatInterface
+{
+ /**
+ * Sets the locale.
+ *
+ * @param string $locale The locale (i.e. "en_US").
+ *
+ * @return self
+ */
+ public function setLocale($locale);
+
+ /**
+ * Sets the numbering system.
+ *
+ * @param string $numberingSystem One of the NUMBERING_SYSTEM_ constants.
+ *
+ * @return self
+ */
+ public function setNumberingSystem($numberingSystem);
+
+ /**
+ * Sets the decimal separator.
+ *
+ * @param string $decimalSeparator
+ *
+ * @return self
+ */
+ public function setDecimalSeparator($decimalSeparator);
+
+ /**
+ * Sets the grouping separator.
+ *
+ * @param string $groupingSeparator
+ *
+ * @return self
+ */
+ public function setGroupingSeparator($groupingSeparator);
+
+ /**
+ * Sets the plus sign.
+ *
+ * @param string $plusSign
+ *
+ * @return self
+ */
+ public function setPlusSign($plusSign);
+
+ /**
+ * Sets the minus sign.
+ *
+ * @param string $minusSign
+ *
+ * @return self
+ */
+ public function setMinusSign($minusSign);
+
+ /**
+ * Sets the percent sign.
+ *
+ * @param string $percentSign
+ *
+ * @return self
+ */
+ public function setPercentSign($percentSign);
+
+ /**
+ * Sets the number pattern used to format decimal numbers.
+ *
+ * @param string $decimalPattern The decimal pattern.
+ *
+ * @return self
+ */
+ public function setDecimalPattern($decimalPattern);
+
+ /**
+ * Sets the number pattern used to format percentages.
+ *
+ * @param string $percentPattern The percent pattern.
+ *
+ * @return self
+ */
+ public function setPercentPattern($percentPattern);
+
+ /**
+ * Sets the number pattern used to format currency amounts.
+ *
+ * @param string $currencyPattern The currency pattern.
+ *
+ * @return self
+ */
+ public function setCurrencyPattern($currencyPattern);
+
+ /**
+ * Sets the number pattern used to format accounting currency amounts.
+ *
+ * Most commonly used when formatting amounts on invoices.
+ *
+ * @param string $accountingCurrencyPattern The accounting currency pattern.
+ *
+ * @return self
+ */
+ public function setAccountingCurrencyPattern($accountingCurrencyPattern);
+}
diff --git a/vendor/commerceguys/intl/src/NumberFormat/NumberFormatInterface.php b/vendor/commerceguys/intl/src/NumberFormat/NumberFormatInterface.php
new file mode 100644
index 000000000..bb343f366
--- /dev/null
+++ b/vendor/commerceguys/intl/src/NumberFormat/NumberFormatInterface.php
@@ -0,0 +1,106 @@
+<?php
+
+namespace CommerceGuys\Intl\NumberFormat;
+
+interface NumberFormatInterface
+{
+ // Arabic-Indic digits.
+ const NUMBERING_SYSTEM_ARABIC = 'arab';
+ // Extended Arabic-Indic digits.
+ const NUMBERING_SYSTEM_ARABIC_EXTENDED = 'arabext';
+ // Bengali digits.
+ const NUMBERING_SYSTEM_BENGALI = 'beng';
+ // Devanagari digits.
+ const NUMBERING_SYSTEM_DEVANAGARI = 'deva';
+ // Latin digits
+ const NUMBERING_SYSTEM_LATIN = 'latn';
+
+ /**
+ * Gets the locale.
+ *
+ * @return string
+ */
+ public function getLocale();
+
+ /**
+ * Gets the numbering system.
+ *
+ * The value is one of the NUMBERING_SYSTEM_ constants.
+ *
+ * @return string
+ */
+ public function getNumberingSystem();
+
+ /**
+ * Gets the decimal separator.
+ *
+ * @return string
+ */
+ public function getDecimalSeparator();
+
+ /**
+ * Gets the grouping separator.
+ *
+ * @return string
+ */
+ public function getGroupingSeparator();
+
+ /**
+ * Gets the plus sign.
+ *
+ * @return string
+ */
+ public function getPlusSign();
+
+ /**
+ * Gets the minus sign.
+ *
+ * @return string
+ */
+ public function getMinusSign();
+
+ /**
+ * Gets the percent sign.
+ *
+ * @return string
+ */
+ public function getPercentSign();
+
+ /**
+ * Gets the number pattern used to format decimal numbers.
+ *
+ * @return string
+ *
+ * @see http://cldr.unicode.org/translation/number-patterns
+ */
+ public function getDecimalPattern();
+
+ /**
+ * Gets the number pattern used to format percentages.
+ *
+ * @return string
+ *
+ * @see http://cldr.unicode.org/translation/number-patterns
+ */
+ public function getPercentPattern();
+
+ /**
+ * Gets the number pattern used to format currency amounts.
+ *
+ * @return string
+ *
+ * @see http://cldr.unicode.org/translation/number-patterns
+ */
+ public function getCurrencyPattern();
+
+ /**
+ * Gets the number pattern used to format accounting currency amounts.
+ *
+ * Most commonly used when formatting amounts on invoices.
+ *
+ * @return string
+ *
+ * @see http://cldr.unicode.org/translation/number-patterns
+ */
+ public function getAccountingCurrencyPattern();
+}
diff --git a/vendor/commerceguys/intl/src/NumberFormat/NumberFormatRepository.php b/vendor/commerceguys/intl/src/NumberFormat/NumberFormatRepository.php
new file mode 100644
index 000000000..368eb7e2b
--- /dev/null
+++ b/vendor/commerceguys/intl/src/NumberFormat/NumberFormatRepository.php
@@ -0,0 +1,91 @@
+<?php
+
+namespace CommerceGuys\Intl\NumberFormat;
+
+use CommerceGuys\Intl\LocaleResolverTrait;
+
+/**
+ * Repository for number formats based on JSON definitions.
+ */
+class NumberFormatRepository implements NumberFormatRepositoryInterface
+{
+ use LocaleResolverTrait;
+
+ /**
+ * Number formats.
+ *
+ * @var array
+ */
+ protected $numberFormats = [];
+
+ /**
+ * Creates a NumberFormatRepository instance.
+ *
+ * @param string $definitionPath The path to the number format definitions.
+ * Defaults to 'resources/number_format'.
+ */
+ public function __construct($definitionPath = null)
+ {
+ $this->definitionPath = $definitionPath ? $definitionPath : __DIR__ . '/../../resources/number_format/';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get($locale, $fallbackLocale = null)
+ {
+ $locale = $this->resolveLocale($locale, $fallbackLocale);
+ if (!isset($this->numberFormats[$locale])) {
+ $filename = $this->definitionPath . $locale . '.json';
+ $definition = json_decode(file_get_contents($filename), true);
+ $this->numberFormats[$locale] = $this->createNumberFormatFromDefinition($definition, $locale);
+ }
+
+ return $this->numberFormats[$locale];
+ }
+
+ /**
+ * Creates a number format object from the provided definition.
+ *
+ * @param array $definition The number format definition.
+ * @param string $locale The locale of the number format definition.
+ *
+ * @return NumberFormat
+ */
+ protected function createNumberFormatFromDefinition(array $definition, $locale)
+ {
+ if (!isset($definition['decimal_separator'])) {
+ $definition['decimal_separator'] = '.';
+ }
+ if (!isset($definition['grouping_separator'])) {
+ $definition['grouping_separator'] = ',';
+ }
+ if (!isset($definition['plus_sign'])) {
+ $definition['plus_sign'] = '+';
+ }
+ if (!isset($definition['minus_sign'])) {
+ $definition['minus_sign'] = '-';
+ }
+ if (!isset($definition['percent_sign'])) {
+ $definition['percent_sign'] = '%';
+ }
+
+ $numberFormat = new NumberFormat();
+ $setValues = \Closure::bind(function ($definition, $locale) {
+ $this->locale = $locale;
+ $this->numberingSystem = $definition['numbering_system'];
+ $this->decimalSeparator = $definition['decimal_separator'];
+ $this->groupingSeparator = $definition['grouping_separator'];
+ $this->plusSign = $definition['plus_sign'];
+ $this->minusSign = $definition['minus_sign'];
+ $this->percentSign = $definition['percent_sign'];
+ $this->decimalPattern = $definition['decimal_pattern'];
+ $this->percentPattern = $definition['percent_pattern'];
+ $this->currencyPattern = $definition['currency_pattern'];
+ $this->accountingCurrencyPattern = $definition['accounting_currency_pattern'];
+ }, $numberFormat, '\CommerceGuys\Intl\NumberFormat\NumberFormat');
+ $setValues($definition, $locale);
+
+ return $numberFormat;
+ }
+}
diff --git a/vendor/commerceguys/intl/src/NumberFormat/NumberFormatRepositoryInterface.php b/vendor/commerceguys/intl/src/NumberFormat/NumberFormatRepositoryInterface.php
new file mode 100644
index 000000000..ff162b522
--- /dev/null
+++ b/vendor/commerceguys/intl/src/NumberFormat/NumberFormatRepositoryInterface.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace CommerceGuys\Intl\NumberFormat;
+
+/**
+ * Number format repository interface.
+ */
+interface NumberFormatRepositoryInterface
+{
+ /**
+ * Returns a number format instance for the provided locale.
+ *
+ * @param string $locale The locale (i.e. fr-FR).
+ * @param string $fallbackLocale A fallback locale (i.e "en").
+ *
+ * @return NumberFormatInterface
+ */
+ public function get($locale, $fallbackLocale = null);
+}