Issues (662)

src/Numbers/Numbers.php (10 issues)

Labels
Severity
1
<?php
2
3
namespace ICanBoogie\CLDR\Numbers;
4
5
use ArrayObject;
6
use ICanBoogie\CLDR\Core\Locale;
7
8
/**
9
 * Numbers for a locale.
10
 *
11
 * @extends ArrayObject<string, mixed>
12
 *
13
 * @link https://www.unicode.org/reports/tr35/tr35-72/tr35-numbers.html#1-numbering-systems
14
 */
15
final class Numbers extends ArrayObject
16
{
17
    public readonly Symbols $symbols;
18
19
    /**
20
     * Indicates which numbering system should be used for presentation of numeric quantities in the given locale.
21
     */
22
    public readonly string $default_numbering_system;
23
24
    /**
25
     * @phpstan-ignore-next-line
26
     */
27
    public readonly array $decimal_formats;
28
29
    /**
30
     * The standard decimal format of the default numbering system; for example, "#,##0.###".
31
     *
32
     * Shortcut to `decimalFormats-numberSystem-$default_numbering_system/standard`.
33
     */
34
    public readonly string $standard_decimal_format;
35
36
    /**
37
     * Shortcut to `decimalFormats-numberSystem-$default_numbering_system/short/decimalFormats`.
38
     *
39
     * @phpstan-ignore-next-line
40
     */
41
    public readonly array $short_decimal_formats;
42
43
    /**
44
     * Shortcut to `decimalFormats-numberSystem-$default_numbering_system/long/decimalFormats`.
45
     *
46
     * @phpstan-ignore-next-line
47
     */
48
    public readonly array $long_decimal_formats;
49
50
    /**
51
     * Shortcut to `scientificFormats-numberSystem-$default_numbering_system`.
52
     *
53
     * @phpstan-ignore-next-line
54
     */
55
    public readonly array $scientific_formats;
56
57
    /**
58
     * Shortcut to `percentFormats-numberSystem-$default_numbering_system`.
59
     *
60
     * @phpstan-ignore-next-line
61
     */
62
    public readonly array $percent_formats;
63
64
    /**
65
     * Shortcut to `currencyFormats-numberSystem-$default_numbering_system`.
66
     *
67
     * @phpstan-ignore-next-line
68
     */
69
    public readonly array $currency_formats;
70
71
    /**
72
     * Shortcut to `miscPatterns-numberSystem-$default_numbering_system`.
73
     *
74
     * @phpstan-ignore-next-line
75
     */
76
    public readonly array $misc_patterns;
77
78
    /**
79
     * @param array<string, mixed> $data
80
     *
81
     * @link https://github.com/unicode-org/cldr-json/blob/47.0.0/cldr-json/cldr-numbers-full/main/en-001/numbers.json
82
     */
83
    public function __construct(
84
        public readonly Locale $locale,
85
        array $data
86
    ) {
87
        parent::__construct($data);
88
89
        $this->default_numbering_system = $dns = $data['defaultNumberingSystem'];
0 ignored issues
show
The property default_numbering_system is declared read-only in ICanBoogie\CLDR\Numbers\Numbers.
Loading history...
90
        $this->decimal_formats = $data["decimalFormats-numberSystem-$dns"];
0 ignored issues
show
The property decimal_formats is declared read-only in ICanBoogie\CLDR\Numbers\Numbers.
Loading history...
91
        $this->standard_decimal_format = $this->decimal_formats['standard'];
0 ignored issues
show
The property standard_decimal_format is declared read-only in ICanBoogie\CLDR\Numbers\Numbers.
Loading history...
92
        $this->short_decimal_formats = $this->decimal_formats['short']['decimalFormat'];
0 ignored issues
show
The property short_decimal_formats is declared read-only in ICanBoogie\CLDR\Numbers\Numbers.
Loading history...
93
        $this->long_decimal_formats = $this->decimal_formats['long']['decimalFormat'];
0 ignored issues
show
The property long_decimal_formats is declared read-only in ICanBoogie\CLDR\Numbers\Numbers.
Loading history...
94
        $this->scientific_formats = $data["scientificFormats-numberSystem-$dns"];
0 ignored issues
show
The property scientific_formats is declared read-only in ICanBoogie\CLDR\Numbers\Numbers.
Loading history...
95
        $this->percent_formats = $data["percentFormats-numberSystem-$dns"];
0 ignored issues
show
The property percent_formats is declared read-only in ICanBoogie\CLDR\Numbers\Numbers.
Loading history...
96
        $this->currency_formats = $data["currencyFormats-numberSystem-$dns"];
0 ignored issues
show
The property currency_formats is declared read-only in ICanBoogie\CLDR\Numbers\Numbers.
Loading history...
97
        $this->misc_patterns = $data["miscPatterns-numberSystem-$dns"];
0 ignored issues
show
The property misc_patterns is declared read-only in ICanBoogie\CLDR\Numbers\Numbers.
Loading history...
98
        $this->symbols = Symbols::from($data["symbols-numberSystem-$dns"]);
0 ignored issues
show
The property symbols is declared read-only in ICanBoogie\CLDR\Numbers\Numbers.
Loading history...
99
    }
100
}
101