key = $key; $this->params = $params; $this->message = $message; } /** @inheritDoc */ public function toJsonArray(): array { $result = [ 'key' => $this->key ]; if ( $this->message !== null ) { $result['message'] = $this->message; } if ( $this->params !== [] ) { $result['params'] = $this->params; } return $result; } /** @inheritDoc */ public static function newFromJsonArray( array $json ): DataMwError { return new DataMwError( $json['key'], $json['params'] ?? [], $json['message'] ?? null ); } }