|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ICanBoogie\CLDR\Numbers; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Defines the localized symbols that are commonly used when formatting numbers in a given locale. |
|
7
|
|
|
* |
|
8
|
|
|
* @link https://unicode.org/reports/tr35/tr35-numbers.html#Number_Symbols |
|
9
|
|
|
*/ |
|
10
|
|
|
final class Symbols |
|
11
|
|
|
{ |
|
12
|
|
|
private const DEFAULTS = [ |
|
13
|
|
|
|
|
14
|
|
|
'decimal' => '.', |
|
15
|
|
|
'group' => ',', |
|
16
|
|
|
'list' => ';', |
|
17
|
|
|
'percentSign' => '%', |
|
18
|
|
|
'minusSign' => '-', |
|
19
|
|
|
'plusSign' => '+', |
|
20
|
|
|
'approximatelySign' => '~', |
|
21
|
|
|
'exponential' => 'E', |
|
22
|
|
|
'superscriptingExponent' => '×', |
|
23
|
|
|
'perMille' => '‰', |
|
24
|
|
|
'infinity' => '∞', |
|
25
|
|
|
'nan' => '☹', |
|
26
|
|
|
'currencyDecimal' => '.', |
|
27
|
|
|
'currencyGroup' => ',', |
|
28
|
|
|
'timeSeparator' => ':', |
|
29
|
|
|
|
|
30
|
|
|
]; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param array<string, string> $symbols |
|
34
|
|
|
*/ |
|
35
|
|
|
public static function from(array $symbols): self |
|
36
|
|
|
{ |
|
37
|
|
|
$symbols += self::DEFAULTS; |
|
38
|
|
|
|
|
39
|
|
|
return new self( |
|
40
|
|
|
$symbols['decimal'], |
|
41
|
|
|
$symbols['group'], |
|
42
|
|
|
$symbols['list'], |
|
43
|
|
|
$symbols['percentSign'], |
|
44
|
|
|
$symbols['minusSign'], |
|
45
|
|
|
$symbols['plusSign'], |
|
46
|
|
|
$symbols['approximatelySign'], |
|
47
|
|
|
$symbols['exponential'], |
|
48
|
|
|
$symbols['superscriptingExponent'], |
|
49
|
|
|
$symbols['perMille'], |
|
50
|
|
|
$symbols['infinity'], |
|
51
|
|
|
$symbols['nan'], |
|
52
|
|
|
$symbols['currencyDecimal'], |
|
53
|
|
|
$symbols['currencyGroup'], |
|
54
|
|
|
$symbols['timeSeparator'] |
|
55
|
|
|
); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public static function defaults(): self |
|
59
|
|
|
{ |
|
60
|
|
|
static $defaults; |
|
61
|
|
|
|
|
62
|
|
|
return $defaults ??= self::from(self::DEFAULTS); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function __construct( |
|
66
|
|
|
public readonly string $decimal = '.', |
|
67
|
|
|
public readonly string $group = ',', |
|
68
|
|
|
public readonly string $list = ';', |
|
69
|
|
|
public readonly string $percentSign = '%', |
|
70
|
|
|
public readonly string $minusSign = '-', |
|
71
|
|
|
public readonly string $plusSign = '+', |
|
72
|
|
|
public readonly string $approximatelySign = '~', |
|
73
|
|
|
public readonly string $exponential = 'E', |
|
74
|
|
|
public readonly string $superscriptingExponent = '×', |
|
75
|
|
|
public readonly string $perMille = '‰', |
|
76
|
|
|
public readonly string $infinity = '∞', |
|
77
|
|
|
public readonly string $nan = '☹', |
|
78
|
|
|
public readonly string $currencyDecimal = '.', |
|
79
|
|
|
public readonly string $currencyGroup = ',', |
|
80
|
|
|
public readonly string $timeSeparator = ':' |
|
81
|
|
|
) { |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|