35 public static function create( $msg, $code =
null, ?array $data =
null ) {
36 if ( is_array( $msg ) ) {
38 if ( isset( $msg[
'message'] ) ) {
39 $msg = [ $msg[
'message'], ...$msg[
'params'] ?? [] ];
65 public function __construct( $msg, $code =
null, ?array $data =
null ) {
66 if ( $msg instanceof
Message ) {
67 foreach ( get_class_vars( get_class( $this ) ) as
$key => $value ) {
68 if ( isset( $msg->$key ) ) {
69 $this->
$key = $msg->$key;
72 } elseif ( is_array( $msg ) ) {
73 $key = array_shift( $msg );
74 parent::__construct(
$key, $msg );
76 parent::__construct( $msg );
83class_alias( ApiMessage::class,
'ApiMessage' );
trait ApiMessageTrait
Trait to implement the IApiMessage interface for Message subclasses.