Debian Codegraph @

includes/Message/MessageFormatterFactory.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Message;
4
5 use Wikimedia\Message\IMessageFormatterFactory;
6 use Wikimedia\Message\ITextFormatter;
7
8 /**
9 * The MediaWiki-specific implementation of IMessageFormatterFactory
10 */
11 class MessageFormatterFactory implements IMessageFormatterFactory {
12
13 /** @var string */
14 private $format;
15
16 /** @var array */
17 private $textFormatters = [];
18
19 /**
20 * Required parameters may be added to this function without deprecation.
21 * External callers should use MediaWikiServices::getMessageFormatterFactory().
22 *
23 * @param string $format which if the Message::FORMAT_* to use in the formatters.
24 * @internal
25 */
26 public function __construct( string $format = Message::FORMAT_TEXT ) {
27 $this->format = $format;
28 }
29
30 /**
31 * @inheritDoc
32 */
33 public function getTextFormatter( $langCode ): ITextFormatter {
34 if ( !isset( $this->textFormatters[$langCode] ) ) {
35 $this->textFormatters[$langCode] = new TextFormatter(
36 $langCode, $this->format );
37 }
38 return $this->textFormatters[$langCode];
39 }
40 }