Page MenuHomeWickedGov Phorge

TextFormatter.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

TextFormatter.php

<?php
namespace MediaWiki\Message;
use Wikimedia\Message\ITextFormatter;
use Wikimedia\Message\MessageSpecifier;
/**
* The MediaWiki-specific implementation of ITextFormatter
*/
class TextFormatter implements ITextFormatter {
/** @var string */
private $langCode;
/** @var string */
private $format;
/**
* Construct a TextFormatter.
*
* The type signature may change without notice as dependencies are added
* to the constructor. External callers should use
* MediaWikiServices::getMessageFormatterFactory()
*
* @internal
* @param string $langCode
* @param string $format
*/
public function __construct(
string $langCode,
string $format = Message::FORMAT_TEXT
) {
$this->langCode = $langCode;
$this->format = $format;
}
public function getLangCode() {
return $this->langCode;
}
/**
* Allow the Message class to be mocked in tests by constructing objects in
* a protected method.
*
* @internal
* @param MessageSpecifier $spec
* @return Message
*/
protected function createMessage( MessageSpecifier $spec ) {
return Message::newFromSpecifier( $spec );
}
public function format( MessageSpecifier $mv ): string {
$message = $this->createMessage( $mv );
$message->inLanguage( $this->langCode );
return $message->toString( $this->format );
}
}

File Metadata

Mime Type
text/x-php
Expires
Aug 18 2026, 11:15 (5 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0d/14/2d034674af3948942626d5e41f58
Default Alt Text
TextFormatter.php (1 KB)

Event Timeline