MediaWiki REL1_34
ListParam.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\Message;
4
10class ListParam extends MessageParam {
11 private $listType;
12
18 public function __construct( $listType, array $elements ) {
19 $this->type = ParamType::LIST;
20 $this->listType = $listType;
21 $this->value = [];
22 foreach ( $elements as $element ) {
23 if ( $element instanceof MessageParam ) {
24 $this->value[] = $element;
25 } elseif ( is_scalar( $element ) || $element instanceof MessageValue ) {
26 $this->value[] = new ScalarParam( ParamType::TEXT, $element );
27 } else {
28 throw new \InvalidArgumentException(
29 'ListParam elements must be MessageParam or scalar' );
30 }
31 }
32 }
33
39 public function getListType() {
40 return $this->listType;
41 }
42
43 public function dump() {
44 $contents = '';
45 foreach ( $this->value as $element ) {
46 $contents .= $element->dump();
47 }
48 return "<{$this->type} listType=\"{$this->listType}\">$contents</{$this->type}>";
49 }
50}
Value object representing a message parameter that consists of a list of values.
Definition ListParam.php:10
__construct( $listType, array $elements)
Definition ListParam.php:18
getListType()
Get the type of the list.
Definition ListParam.php:39
dump()
Dump the object for testing/debugging.
Definition ListParam.php:43
Value object representing a message parameter that consists of a list of values.
Value object representing a message for i18n.
const LIST
A list of values.
Definition ParamType.php:48
const TEXT
A simple text string or another MessageValue, not otherwise formatted.
Definition ParamType.php:13
Value object representing a message parameter holding a single value.