MediaWiki  1.34.0
Wikimedia\Message\MessageValue Class Reference

Value object representing a message for i18n. More...

Collaboration diagram for Wikimedia\Message\MessageValue:

Public Member Functions

 __construct ( $key, $params=[])
 
 bitrateParams (... $values)
 Chainable mutator which adds parameters which are a number of bits per second (ParamType::BITRATE). More...
 
 commaListParams (... $values)
 Chainable mutator which adds comma lists (ListType::COMMA). More...
 
 dump ()
 Dump the object for testing/debugging. More...
 
 expiryParams (... $values)
 Chainable mutator which adds parameters which are an expiry timestamp (ParamType::EXPIRY). More...
 
 getKey ()
 Get the message key. More...
 
 getParams ()
 Get the parameter array. More...
 
 listParamsOfType ( $listType,... $values)
 Chainable mutator which adds list parameters with a common type. More...
 
 longDurationParams (... $values)
 Chainable mutator which adds parameters which are a duration specified in seconds (ParamType::DURATION_LONG). More...
 
 numParams (... $values)
 Chainable mutator which adds numeric parameters (ParamType::NUM). More...
 
 params (... $values)
 Chainable mutator which adds text parameters and MessageParam parameters. More...
 
 pipeListParams (... $values)
 Chainable mutator which adds pipe lists (ListType::PIPE). More...
 
 plaintextParams (... $values)
 Chainable mutator which adds plaintext parameters (ParamType::PLAINTEXT). More...
 
 rawParams (... $values)
 Chainable mutator which adds "raw" parameters (ParamType::RAW). More...
 
 semicolonListParams (... $values)
 Chainable mutator which adds semicolon lists (ListType::SEMICOLON). More...
 
 shortDurationParams (... $values)
 Chainable mutator which adds parameters which are a duration specified in seconds (ParamType::DURATION_SHORT). More...
 
 sizeParams (... $values)
 Chainable mutator which adds parameters which are a number of bytes (ParamType::SIZE). More...
 
 textListParams (... $values)
 Chainable mutator which adds natural-language lists (ListType::AND). More...
 
 textParams (... $values)
 Chainable mutator which adds parameters of type text (ParamType::TEXT). More...
 
 textParamsOfType ( $type,... $values)
 Chainable mutator which adds text parameters with a common type. More...
 

Private Attributes

string $key
 
MessageParam[] $params
 

Detailed Description

Value object representing a message for i18n.

A MessageValue holds a key and an array of parameters. It can be converted to a string in a particular language using formatters obtained from an IMessageFormatterFactory.

MessageValues are pure value objects and are safely newable.

Definition at line 14 of file MessageValue.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Message\MessageValue::__construct (   $key,
  $params = [] 
)
Parameters
string$key
(MessageParam|MessageValue|string|int|float)[]$params Values that are not instances of MessageParam are wrapped using ParamType::TEXT.

Definition at line 26 of file MessageValue.php.

References Wikimedia\Message\MessageValue\$key, and Wikimedia\Message\MessageValue\params().

Member Function Documentation

◆ bitrateParams()

Wikimedia\Message\MessageValue::bitrateParams (   $values)

Chainable mutator which adds parameters which are a number of bits per second (ParamType::BITRATE).

Parameters
int|float...$values
Returns
MessageValue

Definition at line 172 of file MessageValue.php.

References Wikimedia\Message\ParamType\BITRATE, and Wikimedia\Message\MessageValue\textParamsOfType().

◆ commaListParams()

Wikimedia\Message\MessageValue::commaListParams (   $values)

Chainable mutator which adds comma lists (ListType::COMMA).

The list parameters thus created are formatted as a comma-separated list, or some local equivalent.

Parameters
(MessageParam|MessageValue|string|int|float)[]...$values Each value is an array of items suitable to pass as $params to ListParam::__construct()
Returns
MessageValue

Definition at line 214 of file MessageValue.php.

References Wikimedia\Message\ListType\COMMA, and Wikimedia\Message\MessageValue\listParamsOfType().

◆ dump()

Wikimedia\Message\MessageValue::dump ( )

Dump the object for testing/debugging.

Returns
string

Definition at line 265 of file MessageValue.php.

References Wikimedia\Message\MessageValue\params().

◆ expiryParams()

Wikimedia\Message\MessageValue::expiryParams (   $values)

Chainable mutator which adds parameters which are an expiry timestamp (ParamType::EXPIRY).

Parameters
string...$values Timestamp as accepted by the Wikimedia\Timestamp library, or "infinity"
Returns
MessageValue

Definition at line 151 of file MessageValue.php.

References Wikimedia\Message\ParamType\EXPIRY, and Wikimedia\Message\MessageValue\textParamsOfType().

◆ getKey()

Wikimedia\Message\MessageValue::getKey ( )

Get the message key.

Returns
string

Definition at line 37 of file MessageValue.php.

References Wikimedia\Message\MessageValue\$key.

◆ getParams()

Wikimedia\Message\MessageValue::getParams ( )

Get the parameter array.

Returns
MessageParam[]

Definition at line 46 of file MessageValue.php.

References Wikimedia\Message\MessageValue\$params.

◆ listParamsOfType()

Wikimedia\Message\MessageValue::listParamsOfType (   $listType,
  $values 
)

Chainable mutator which adds list parameters with a common type.

Parameters
string$listTypeOne of the ListType constants
(MessageParam|MessageValue|string|int|float)[]...$values Each value is an array of items suitable to pass as $params to ListParam::__construct()
Returns
MessageValue

Definition at line 89 of file MessageValue.php.

References Wikimedia\Message\MessageValue\params().

Referenced by Wikimedia\Message\MessageValue\commaListParams(), Wikimedia\Message\MessageValue\pipeListParams(), Wikimedia\Message\MessageValue\semicolonListParams(), and Wikimedia\Message\MessageValue\textListParams().

◆ longDurationParams()

Wikimedia\Message\MessageValue::longDurationParams (   $values)

Chainable mutator which adds parameters which are a duration specified in seconds (ParamType::DURATION_LONG).

This is similar to shorDurationParams() except that the result will be more verbose.

Parameters
int|float...$values
Returns
MessageValue

Definition at line 126 of file MessageValue.php.

References Wikimedia\Message\ParamType\DURATION_LONG, and Wikimedia\Message\MessageValue\textParamsOfType().

◆ numParams()

Wikimedia\Message\MessageValue::numParams (   $values)

Chainable mutator which adds numeric parameters (ParamType::NUM).

Parameters
int|float...$values
Returns
MessageValue

Definition at line 112 of file MessageValue.php.

References Wikimedia\Message\ParamType\NUM, and Wikimedia\Message\MessageValue\textParamsOfType().

◆ params()

Wikimedia\Message\MessageValue::params (   $values)

Chainable mutator which adds text parameters and MessageParam parameters.

Parameters
MessageParam|MessageValue|string|int|float...$values
Returns
MessageValue

Definition at line 56 of file MessageValue.php.

References Wikimedia\Message\ParamType\TEXT.

Referenced by Wikimedia\Message\MessageValue\__construct(), Wikimedia\Message\MessageValue\dump(), Wikimedia\Message\MessageValue\listParamsOfType(), and Wikimedia\Message\MessageValue\textParamsOfType().

◆ pipeListParams()

Wikimedia\Message\MessageValue::pipeListParams (   $values)

Chainable mutator which adds pipe lists (ListType::PIPE).

The list parameters thus created are formatted as a pipe ("|") -separated list, or some local equivalent.

Parameters
(MessageParam|MessageValue|string|int|float)[]...$values Each value is an array of items suitable to pass as $params to ListParam::__construct()
Returns
MessageValue

Definition at line 242 of file MessageValue.php.

References Wikimedia\Message\MessageValue\listParamsOfType(), and Wikimedia\Message\ListType\PIPE.

◆ plaintextParams()

Wikimedia\Message\MessageValue::plaintextParams (   $values)

Chainable mutator which adds plaintext parameters (ParamType::PLAINTEXT).

Plaintext parameters are substituted after formatter processing. The value will be escaped by the formatter as appropriate for the target output format so as to be represented as plain text rather than as any sort of markup.

Parameters
string...$values
Returns
MessageValue

Definition at line 200 of file MessageValue.php.

References Wikimedia\Message\ParamType\PLAINTEXT, and Wikimedia\Message\MessageValue\textParamsOfType().

◆ rawParams()

Wikimedia\Message\MessageValue::rawParams (   $values)

Chainable mutator which adds "raw" parameters (ParamType::RAW).

Raw parameters are substituted after formatter processing. The caller is responsible for ensuring that the value will be safe for the intended output format, and documenting what that intended output format is.

Parameters
string...$values
Returns
MessageValue

Definition at line 186 of file MessageValue.php.

References Wikimedia\Message\ParamType\RAW, and Wikimedia\Message\MessageValue\textParamsOfType().

◆ semicolonListParams()

Wikimedia\Message\MessageValue::semicolonListParams (   $values)

Chainable mutator which adds semicolon lists (ListType::SEMICOLON).

The list parameters thus created are formatted as a semicolon-separated list, or some local equivalent.

Parameters
(MessageParam|MessageValue|string|int|float)[]...$values Each value is an array of items suitable to pass as $params to ListParam::__construct()
Returns
MessageValue

Definition at line 228 of file MessageValue.php.

References Wikimedia\Message\MessageValue\listParamsOfType(), and Wikimedia\Message\ListType\SEMICOLON.

◆ shortDurationParams()

Wikimedia\Message\MessageValue::shortDurationParams (   $values)

Chainable mutator which adds parameters which are a duration specified in seconds (ParamType::DURATION_SHORT).

This is similar to longDurationParams() except that the result will be more compact.

Parameters
int|float...$values
Returns
MessageValue

Definition at line 140 of file MessageValue.php.

References Wikimedia\Message\ParamType\DURATION_SHORT, and Wikimedia\Message\MessageValue\textParamsOfType().

◆ sizeParams()

Wikimedia\Message\MessageValue::sizeParams (   $values)

Chainable mutator which adds parameters which are a number of bytes (ParamType::SIZE).

Parameters
int...$values
Returns
MessageValue

Definition at line 161 of file MessageValue.php.

References Wikimedia\Message\ParamType\SIZE, and Wikimedia\Message\MessageValue\textParamsOfType().

◆ textListParams()

Wikimedia\Message\MessageValue::textListParams (   $values)

Chainable mutator which adds natural-language lists (ListType::AND).

The list parameters thus created, when formatted, are joined as in natural language. In English, this means a comma-separated list, with the last two elements joined with "and".

Parameters
(MessageParam|string)[]...$values
Returns
MessageValue

Definition at line 256 of file MessageValue.php.

References Wikimedia\Message\ListType\AND, and Wikimedia\Message\MessageValue\listParamsOfType().

◆ textParams()

Wikimedia\Message\MessageValue::textParams (   $values)

Chainable mutator which adds parameters of type text (ParamType::TEXT).

Parameters
MessageValue|string|int|float...$values
Returns
MessageValue

Definition at line 102 of file MessageValue.php.

References Wikimedia\Message\ParamType\TEXT, and Wikimedia\Message\MessageValue\textParamsOfType().

◆ textParamsOfType()

Wikimedia\Message\MessageValue::textParamsOfType (   $type,
  $values 
)

Member Data Documentation

◆ $key

string Wikimedia\Message\MessageValue::$key
private

◆ $params

MessageParam [] Wikimedia\Message\MessageValue::$params
private

Definition at line 19 of file MessageValue.php.

Referenced by Wikimedia\Message\MessageValue\getParams().


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