aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/commerceguys/intl/src/Formatter/NumberFormatterInterface.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/commerceguys/intl/src/Formatter/NumberFormatterInterface.php')
-rw-r--r--vendor/commerceguys/intl/src/Formatter/NumberFormatterInterface.php154
1 files changed, 26 insertions, 128 deletions
diff --git a/vendor/commerceguys/intl/src/Formatter/NumberFormatterInterface.php b/vendor/commerceguys/intl/src/Formatter/NumberFormatterInterface.php
index 3a510be2a..ce6207f52 100644
--- a/vendor/commerceguys/intl/src/Formatter/NumberFormatterInterface.php
+++ b/vendor/commerceguys/intl/src/Formatter/NumberFormatterInterface.php
@@ -2,150 +2,48 @@
namespace CommerceGuys\Intl\Formatter;
-use CommerceGuys\Intl\Currency\CurrencyInterface;
-use CommerceGuys\Intl\NumberFormat\NumberFormatInterface;
+use CommerceGuys\Intl\Currency\Currency;
+use CommerceGuys\Intl\NumberFormat\NumberFormat;
interface NumberFormatterInterface
{
- /* Format style constants */
- const DECIMAL = 1;
- const PERCENT = 2;
- const CURRENCY = 3;
- const CURRENCY_ACCOUNTING = 4;
-
- /* Currency display style constants */
- const CURRENCY_DISPLAY_SYMBOL = 1;
- const CURRENCY_DISPLAY_CODE = 2;
-
/**
* Formats a number.
*
- * Please note that the provided value should already be rounded.
- * This formatter doesn't do any rounding of its own, and will simply
- * truncate extra digits.
- *
- * @param string $value The value to format.
- *
- * @return string
- */
- public function format($value);
-
- /**
- * Formats a currency value.
- *
- * Please note that the provided value should already be rounded.
- * This formatter doesn't do any rounding of its own, and will simply
- * truncate extra digits.
+ * Supported options:
+ * - locale: The locale. Default: 'en'.
+ * - use_grouping: Whether to use grouping separators,
+ * such as thousands separators.
+ * Default: true.
+ * - minimum_fraction_digits: Minimum fraction digits. Default: 0.
+ * - maximum_fraction_digits: Minimum fraction digits. Default: 3.
+ * - rounding_mode: The rounding mode.
+ * A PHP_ROUND_ constant or 'none' to skip
+ * rounding. Default: PHP_ROUND_HALF_UP.
+ * - style: The style.
+ * One of: 'decimal', 'percent'.
+ * Default: 'decimal'.
*
- * @param string $value The value to format.
- * @param CurrencyInterface $currency The currency.
+ * @param string $number The number.
+ * @param array $options The formatting options.
*
- * @return string
+ * @return string The formatted number.
*/
- public function formatCurrency($value, CurrencyInterface $currency);
+ public function format($number, array $options = []);
/**
* Parses a number.
*
* Commonly used in input widgets where the end-user might input
- * a value using digits and symbols common to their locale.
- *
- * @param string $value The value to parse.
- *
- * @return string|false The parsed numeric value or FALSE on error.
- */
- public function parse($value);
-
- /**
- * Parses a formatted currency value.
- *
- * @param string $value The value to parse.
- * @param CurrencyInterface $currency The currency.
- *
- * @return string|false The parsed numeric value or FALSE on error.
- */
- public function parseCurrency($value, CurrencyInterface $currency);
-
- /**
- * Gets the number format.
- *
- * @return NumberFormatInterface
- */
- public function getNumberFormat();
-
- /**
- * Gets the minimum number of fraction digits.
- *
- * Defaults to 0 for decimal and percentage styles.
- * Defaults to null for currency styles, since the currency number of
- * fraction digits is used as the default in that case.
- *
- * @return int
- */
- public function getMinimumFractionDigits();
-
- /**
- * Sets the minimum number of fraction digits.
- *
- * @param int $minimumFractionDigits
+ * a number using digits and symbols common to their locale.
*
- * @return self
- */
- public function setMinimumFractionDigits($minimumFractionDigits);
-
- /**
- * Gets the maximum number of fraction digits.
- *
- * Defaults to 3 for decimal and percentage styles.
- * Defaults to null for currency styles, since the currency number of
- * fraction digits is used as the default in that case.
- *
- * @return int
- */
- public function getMaximumFractionDigits();
-
- /**
- * Sets the maximum number of fraction digits.
- *
- * @param int $maximumFractionDigits
- *
- * @return self
- */
- public function setMaximumFractionDigits($maximumFractionDigits);
-
- /**
- * Returns whether the major digits will be grouped.
- *
- * @return bool
- */
- public function isGroupingUsed();
-
- /**
- * Sets whether or not major digits should be grouped.
- *
- * @param bool $groupingUsed
- *
- * @return self
- */
- public function setGroupingUsed($groupingUsed);
-
- /**
- * Gets the currency display style.
- *
- * Controls whether a currency amount will be shown with the
- * currency symbol (CURRENCY_DISPLAY_SYMBOL) or the
- * currency code (CURRENCY_DISPLAY_CODE).
- *
- * @return int
- */
- public function getCurrencyDisplay();
-
- /**
- * Sets the currency display style.
+ * Supported options:
+ * - locale: The locale. Default: 'en'.
*
- * @param int $currencyDisplay One of the CURRENCY_DISPLAY_ constants.
+ * @param string $number The formatted number.
+ * @param array $options The parsing options.
*
- * @return self
+ * @return string|false The parsed number or FALSE on error.
*/
- public function setCurrencyDisplay($currencyDisplay);
+ public function parse($number, array $options = []);
}