MediaWiki  master
Wikimedia\Message\DataMessageValue Class Reference

Value object representing a message for i18n with alternative machine-readable data. More...

Inheritance diagram for Wikimedia\Message\DataMessageValue:
Collaboration diagram for Wikimedia\Message\DataMessageValue:

Public Member Functions

 __construct ( $key, $params=[], $code=null, array $data=null)
 Stable to call. More...
 
 dump ()
 Dump the object for testing/debugging. More...
 
 getCode ()
 Get the message code. More...
 
 getData ()
 Get the message's structured data. More...
 
- Public Member Functions inherited from Wikimedia\Message\MessageValue
 __construct ( $key, $params=[])
 Stable to call. More...
 
 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...
 
 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...
 

Static Public Member Functions

static new ( $key, $params=[], $code=null, array $data=null)
 Static constructor for easier chaining of ->params() methods. More...
 
- Static Public Member Functions inherited from Wikimedia\Message\MessageValue
static new ( $key, $params=[])
 Static constructor for easier chaining of ->params() methods. More...
 

Private Attributes

string $code
 
array null $data
 

Detailed Description

Value object representing a message for i18n with alternative machine-readable data.

This augments a MessageValue with an additional machine-readable code and structured data. The intended use is to facilitate error reporting in APIs.

For example, a MessageValue reporting an "integer out of range" error might use one of three message keys, depending on whether there is a minimum, a maximum, or both. But an API would likely want to use one code for all three cases, and would likely want the endpoints represented along the lines of ‘[ 'min’ => 1, 'max' => 10 ]rather than [ 0 => new ScalarParam( ParamType::TEXT, 1 ), 1 => new ScalarParam( ParamType::TEXT, 10 ) ]`.

DataMessageValues are pure value objects and are safely newable.

@newable

Definition at line 23 of file DataMessageValue.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Message\DataMessageValue::__construct (   $key,
  $params = [],
  $code = null,
array  $data = null 
)

Stable to call.

Parameters
string$key
(MessageParam|MessageValue|string|int|float)[]$params
string | null$codeString representing the concept behind this message.
array | null$dataStructured data representing the concept behind this message.

Definition at line 40 of file DataMessageValue.php.

References Wikimedia\Message\DataMessageValue\$code, Wikimedia\Message\DataMessageValue\$data, Wikimedia\Message\MessageValue\$key, and Wikimedia\Message\MessageValue\$params.

Member Function Documentation

◆ dump()

Wikimedia\Message\DataMessageValue::dump ( )

Dump the object for testing/debugging.

Returns
string

Reimplemented from Wikimedia\Message\MessageValue.

Definition at line 75 of file DataMessageValue.php.

References Wikimedia\Message\MessageValue\getKey(), and Wikimedia\Message\MessageValue\getParams().

◆ getCode()

Wikimedia\Message\DataMessageValue::getCode ( )

◆ getData()

Wikimedia\Message\DataMessageValue::getData ( )

◆ new()

Member Data Documentation

◆ $code

string Wikimedia\Message\DataMessageValue::$code
private

◆ $data

array null Wikimedia\Message\DataMessageValue::$data
private

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