5use InvalidArgumentException;
21 private static $constants =
null;
27 private static function getTypes() {
28 if ( self::$constants ===
null ) {
29 $rc =
new ReflectionClass( ParamType::class );
30 self::$constants = array_values( $rc->getConstants() );
33 return self::$constants;
56 $mv->params( $this->convertParam( $param ) );
66 private function convertParam( $param ) {
67 if ( $param instanceof
Message ) {
70 if ( !is_array( $param ) ) {
74 if ( isset( $param[
'list'] ) && isset( $param[
'type'] ) ) {
75 $convertedElements = [];
76 foreach ( $param[
'list'] as $element ) {
77 $convertedElements[] = $this->convertParam( $element );
79 return new ListParam( $param[
'type'], $convertedElements );
82 foreach ( self::getTypes() as
$type ) {
83 if (
$type !== ParamType::LIST && isset( $param[
$type] ) ) {
84 return new ScalarParam(
$type, $param[
$type] );
88 throw new InvalidArgumentException(
"Unrecognized Message param: " . json_encode( $param ) );
99 $m->params( $this->convertMessageParam( $param ) );
109 private function convertMessageParam(
MessageParam $param ) {
111 $convertedElements = [];
112 foreach ( $param->
getValue() as $element ) {
113 $convertedElements[] = $this->convertMessageParam( $element );
118 if ( $value instanceof MessageValue ) {
122 if ( $param->
getType() === ParamType::TEXT ) {
125 return [ $param->
getType() => $value ];
The Message class deals with fetching and processing of interface message into a variety of formats.
static listParam(array $list, $type='text')
getParams()
Returns the message parameters.
getKey()
Returns the message key.