MediaWiki master
Wikimedia\Leximorph\Manager Class Reference

Manager. More...

Public Member Functions

 __construct (string $langCode, ?LoggerInterface $logger=null)
 Initializes a new Manager instance with a default language code.
 
 getBidi ()
 Get the Bidi handler.
 
 getFormal ()
 Get the Formal handler.
 
 getGender ()
 Get the Gender handler.
 
 getGrammar ()
 Get the Grammar handler.
 
 getPlural ()
 Get the Plural handler.
 

Protected Member Functions

 getSpecArgs (array $spec, LoggerInterface $logger)
 Builds the constructor arguments.
 
 getSpecMap ()
 Get the handler spec map.
 

Detailed Description

Manager.

This class is responsible for instantiating Leximorph handler objects (Grammar, Formal, Gender, Bidi, and Plural) using Wikimedia’s ObjectFactory. The Manager holds a default language code that is injected into language-specific handlers.

Note that Gender and Bidi handlers are language independent.

Usage Example: $manager = new Manager( 'en', new NullLogger() ); $pluralHandler = $manager->getPlural(); echo $pluralHandler->process( 3, [ 'article', 'articles' ] );

Stability: newable
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 41 of file Manager.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Leximorph\Manager::__construct ( string $langCode,
?LoggerInterface $logger = null )

Initializes a new Manager instance with a default language code.

Parameters
string$langCodeThe default language code.
?LoggerInterface$loggerOptional logger; defaults to NullLogger.
Since
1.45

Definition at line 92 of file Manager.php.

Member Function Documentation

◆ getBidi()

Wikimedia\Leximorph\Manager::getBidi ( )

Get the Bidi handler.

Since
1.45
Returns
Bidi

Definition at line 144 of file Manager.php.

◆ getFormal()

Wikimedia\Leximorph\Manager::getFormal ( )

Get the Formal handler.

Since
1.45
Returns
Formal

Definition at line 154 of file Manager.php.

◆ getGender()

Wikimedia\Leximorph\Manager::getGender ( )

Get the Gender handler.

Since
1.45
Returns
Gender

Definition at line 164 of file Manager.php.

◆ getGrammar()

Wikimedia\Leximorph\Manager::getGrammar ( )

Get the Grammar handler.

Since
1.45
Returns
Grammar

Definition at line 174 of file Manager.php.

◆ getPlural()

Wikimedia\Leximorph\Manager::getPlural ( )

Get the Plural handler.

Since
1.45
Returns
Plural

Definition at line 184 of file Manager.php.

◆ getSpecArgs()

Wikimedia\Leximorph\Manager::getSpecArgs ( array $spec,
LoggerInterface $logger )
protected

Builds the constructor arguments.

Parameters
array<string,mixed>$spec
Since
1.45
Returns
array<int,mixed>

Definition at line 117 of file Manager.php.

◆ getSpecMap()

Wikimedia\Leximorph\Manager::getSpecMap ( )
protected

Get the handler spec map.

Returns an array of handler specs indexed by class name.

Since
1.45
Returns
array<class-string, array<string, mixed>>

Definition at line 105 of file Manager.php.


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