MediaWiki master
Wikimedia\Leximorph\Handler\Plural Class Reference

Plural. More...

Public Member Functions

 __construct (private readonly Provider $provider,)
 
 process (float $count, array $forms)
 Selects and returns the pluralized text form based on a numeric count.
 

Detailed Description

Plural.

The Plural class selects the correct text form based on a numeric count and language-specific pluralization rules from the Unicode CLDR. It processes a number along with an array of text options, returning the appropriately pluralized text.

Usage Example: echo $plural->process( 3, [ 'article', 'articles' ] );

Since
1.45
Author
Doğu Abaris (abari.nosp@m.s@nu.nosp@m.ll.ne.nosp@m.t)
Note
https://www.gnu.org/copyleft/gpl.html GPL-2.0-or-later

Definition at line 27 of file Plural.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Leximorph\Handler\Plural::__construct ( private readonly Provider $provider)
Since
1.45

Definition at line 32 of file Plural.php.

Member Function Documentation

◆ process()

Wikimedia\Leximorph\Handler\Plural::process ( float $count,
array $forms )

Selects and returns the pluralized text form based on a numeric count.

This method evaluates the provided numeric count using language-specific pluralization rules derived from the Unicode CLDR. It then selects the appropriate text form from the provided array of alternatives, taking into account any explicit plural forms if specified.

Parameters
float$countThe numeric count to evaluate.
string[]$formsAn array of text forms for pluralization.
Since
1.45
Returns
string The pluralized text corresponding to the count.

Definition at line 50 of file Plural.php.


The documentation for this class was generated from the following file: