MediaWiki master
Wikimedia\Leximorph\Handler\Formal Class Reference

Formal. More...

Public Member Functions

 __construct (private readonly Provider $provider,)
 Initializes the Formal handler with the provider.
 
 process (array $options)
 Selects the appropriate text form based on formality.
 

Detailed Description

Formal.

The Formal class selects the appropriate text form (formal or informal) based on a language-specific formality index. It loads the index from a JSON file and returns either the formal or informal variant provided in the options.

Usage Example: echo $formal->process( [ 'Du hast', 'Sie haben' ] );

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 Formal.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Leximorph\Handler\Formal::__construct ( private readonly Provider $provider)

Initializes the Formal handler with the provider.

Parameters
Provider$providerThe provider instance to use.
Since
1.45

Definition at line 36 of file Formal.php.

Member Function Documentation

◆ process()

Wikimedia\Leximorph\Handler\Formal::process ( array $options)

Selects the appropriate text form based on formality.

Given an array of options containing a formal form and an informal form (with the informal form defaulting to the formal form if not provided), this method returns the form that matches the language-specific formality index loaded from configuration.

Parameters
string[]$optionsAn array with the formal and informal text variants.
Since
1.45
Returns
string The text variant corresponding to the determined formality.

Definition at line 53 of file Formal.php.


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