$data JSON data * @return self */ public static function fromArray(array $data): self { $diag = new self(); $diag->code = $data['code']; $diag->message = $data['message']; $diag->severity = $data['severity']; $diag->page_index = $data['page_index'] ?? null; $diag->hint = $data['hint'] ?? null; if (isset($data['location']) && $data['location'] !== null) { $diag->location = ObjectLocation::fromArray($data['location']); } return $diag; } /** * Convert to JSON array * * @return array */ public function toArray(): array { $data = [ 'code' => $this->code, 'message' => $this->message, 'severity' => $this->severity, ]; if ($this->page_index !== null) { $data['page_index'] = $this->page_index; } if ($this->location !== null) { $data['location'] = $this->location->toArray(); } if ($this->hint !== null) { $data['hint'] = $this->hint; } return $data; } }