-
Notifications
You must be signed in to change notification settings - Fork 45
/
CurrencyFormatterInterface.php
54 lines (51 loc) · 2.11 KB
/
CurrencyFormatterInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace CommerceGuys\Intl\Formatter;
interface CurrencyFormatterInterface
{
/**
* Formats a currency amount.
*
* 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.
* - maximum_fraction_digits: Minimum fraction digits.
* - rounding_mode: The rounding mode.
* A PHP_ROUND_ constant or 'none' to skip
* rounding. Default: PHP_ROUND_HALF_UP.
* - style: The style.
* One of: 'standard', 'accounting'.
* Default: 'standard'.
* - currency_display: How the currency should be displayed.
* One of: 'code', 'symbol', 'none'.
* Default: 'symbol'.
*
* Both minimum_fraction_digits and maximum_fraction_digits default
* to the currency's number of fraction digits.
*
* @param string $number The number.
* @param string $currencyCode The currency code.
* @param array $options The formatting options.
*
* @return string The formatted number.
*/
public function format(string $number, string $currencyCode, array $options = []): string;
/**
* Parses a formatted currency amount.
*
* Commonly used in input widgets where the end-user might input
* a number using digits and symbols common to their locale.
*
* Supported options:
* - locale: The locale. Default: 'en'.
*
* @param string $number The formatted number.
* @param string $currencyCode The currency code.
* @param array $options The parsing options.
*
* @return string|false The parsed number or FALSE on error.
*/
public function parse(string $number, string $currencyCode, array $options = []): string|bool;
}