wiki.techinc.nl/includes/Message/MessageFormatterFactory.php
James D. Forrester eeb5a740b3 Namespace Message, move to appropriate directory
Bug: T353458
Change-Id: I088cbc53fbcdb974e5b05b45a62e91709dacc024
2024-02-14 15:10:36 -05:00

40 lines
1 KiB
PHP

<?php
namespace MediaWiki\Message;
use Wikimedia\Message\IMessageFormatterFactory;
use Wikimedia\Message\ITextFormatter;
/**
* The MediaWiki-specific implementation of IMessageFormatterFactory
*/
class MessageFormatterFactory implements IMessageFormatterFactory {
/** @var string */
private $format;
/** @var array */
private $textFormatters = [];
/**
* Required parameters may be added to this function without deprecation.
* External callers should use MediaWikiServices::getMessageFormatterFactory().
*
* @param string $format which if the Message::FORMAT_* to use in the formatters.
* @internal
*/
public function __construct( string $format = Message::FORMAT_TEXT ) {
$this->format = $format;
}
/**
* @inheritDoc
*/
public function getTextFormatter( $langCode ): ITextFormatter {
if ( !isset( $this->textFormatters[$langCode] ) ) {
$this->textFormatters[$langCode] = new TextFormatter(
$langCode, new Converter(), $this->format );
}
return $this->textFormatters[$langCode];
}
}