39 $mv->params( $this->convertParam( $param ) );
49 private function convertParam( $param ) {
53 if ( !is_array( $param ) ) {
54 return new ScalarParam( ParamType::TEXT, $param );
57 if ( isset( $param[
'list'] ) && isset( $param[
'type'] ) ) {
58 $convertedElements = [];
59 foreach ( $param[
'list'] as $element ) {
60 $convertedElements[] = $this->convertParam( $element );
62 return new ListParam( $param[
'type'], $convertedElements );
65 foreach ( ParamType::cases() as $type ) {
66 if ( $type !== ParamType::LIST && isset( $param[$type] ) ) {
67 return new ScalarParam( $type, $param[$type] );
71 throw new InvalidArgumentException(
"Unrecognized Message param: " . json_encode( $param ) );
82 $m->params( $this->convertMessageParam( $param ) );
92 private function convertMessageParam(
MessageParam $param ) {
94 $convertedElements = [];
95 foreach ( $param->
getValue() as $element ) {
96 $convertedElements[] = $this->convertMessageParam( $element );
101 if ( $value instanceof MessageValue ) {
105 if ( $param->
getType() === ParamType::TEXT ) {
108 return [ $param->
getType() => $value ];