Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
MessageFormatterFactory | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getTextFormatter | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 |
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, new Converter(), $this->format ); |
37 | } |
38 | return $this->textFormatters[$langCode]; |
39 | } |
40 | } |