/** * @return array */ public function toArray() { $content = []; if ($this->hasJsonApi()) { $content["jsonApi"] = $this->jsonApi->toArray(); } if ($this->hasMeta()) { $content["meta"] = $this->meta; } if ($this->hasLinks()) { $content["links"] = $this->links->toArray(); } if ($this->hasPrimaryResources()) { $content["data"] = $this->resources->primaryDataToArray(); } if ($this->hasErrors()) { $errors = []; foreach ($this->errors as $error) { $errors = $error->toArray(); } $content["errors"] = $errors; } if ($this->resources->hasIncludedResources()) { $content["included"] = $this->resources->includedToArray(); } return $content; }