49 public static function create( $msg, $code =
null, array $data =
null ) {
50 if ( is_array( $msg ) ) {
52 if ( isset( $msg[
'message'] ) ) {
53 $msg = [ $msg[
'message'], ...$msg[
'params'] ?? [] ];
79 public function __construct( $msg, $code =
null, array $data =
null ) {
80 if ( $msg instanceof
Message ) {
81 foreach ( get_class_vars( get_class( $this ) ) as
$key => $value ) {
82 if ( isset( $msg->$key ) ) {
83 $this->
$key = $msg->$key;
86 } elseif ( is_array( $msg ) ) {
87 $key = array_shift( $msg );
88 parent::__construct(
$key, $msg );
90 parent::__construct( $msg );
97class_alias( ApiMessage::class,
'ApiMessage' );
trait ApiMessageTrait
Trait to implement the IApiMessage interface for Message subclasses.