PluralRule final readonly class
Minn\I18n\PluralRule · public/minn/src/Minn/I18n/PluralRule.php · 69 lines
A language's plural rule from its Plural-Forms header: how many forms it has and which form a number takes. A file without the header follows English (two forms, n != 1); an expression that does not parse sends every number to the first form, as the reference does.
Constants and properties
| prop | readonly int $count | Promoted from the constructor. |
| prop | readonly string $expression | Promoted from the constructor. |
| private | readonly ?array $tree | Promoted from the constructor. |
Public
| new | __construct(int $count, string $expression, ?array $tree)# |
| |||
| static | english(): self# | English: one form for 1, the other for everything else. | |||
| static | fromHeader(?string $header): self# | The rule a Plural-Forms header states. | |||
| static | fromExpression(int $count, string $expression): self# | A rule from a form count and an expression in n. | |||
| static | parenthesized(string $expression): string# | An expression with each ternary's branches parenthesized, as parenthesize_plural_exression() writes it: "?" becomes " ? (", ":" becomes ") : (", the open parentheses closed at each ";" and at the end, trailing semicolons dropped. | |||
| method | index(int $n): int# | The form a number takes. | |||
| method | pair(): array# | The form count and the expression, as nplurals_and_expression_from_header() answers them. @return array{0: int, 1: string} @return array{0: int, 1: string} | |||
| method | chooser(): Closure# | The form a number takes, as the function make_plural_form_function() hands back. @return \Closure(mixed): int @return \Closure(mixed): int |
Nothing matches.