Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions src/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Tobscure\JsonApi;

use JsonSerializable;
use LogicException;

class Document implements JsonSerializable
{
Expand Down Expand Up @@ -44,14 +43,14 @@ class Document implements JsonSerializable

/**
* Relationships to include.
*
*
* @var array
*/
protected $include = [];

/**
* Sparse fieldsets.
*
*
* @var array
*/
protected $fields = [];
Expand All @@ -66,7 +65,7 @@ public function __construct($data = null)

/**
* Get the data object.
*
*
* @return ResourceInterface|ResourceInterface[]|null $data
*/
public function getData()
Expand All @@ -90,7 +89,7 @@ public function setData($data)

/**
* Get the errors array.
*
*
* @return array|null $errors
*/
public function getErrors()
Expand All @@ -114,7 +113,7 @@ public function setErrors(array $errors = null)

/**
* Get the jsonapi array.
*
*
* @return array|null $jsonapi
*/
public function getJsonapi()
Expand All @@ -138,7 +137,7 @@ public function setJsonapi(array $jsonapi = null)

/**
* Get the relationships to include.
*
*
* @return array $include
*/
public function getInclude()
Expand All @@ -148,7 +147,7 @@ public function getInclude()

/**
* Set the relationships to include.
*
*
* @param array $include
*
* @return $this
Expand All @@ -162,7 +161,7 @@ public function setInclude(array $include)

/**
* Get the sparse fieldsets.
*
*
* @return array $fields
*/
public function getFields()
Expand All @@ -172,7 +171,7 @@ public function getFields()

/**
* Set the sparse fieldsets.
*
*
* @param array $fields
*
* @return $this
Expand Down Expand Up @@ -267,7 +266,7 @@ public function jsonSerialize()

/**
* Recursively add the given resources and their relationships to a map.
*
*
* @param array &$map The map to merge resources into.
* @param ResourceInterface[] $resources
* @param array $include An array of relationship paths to include.
Expand Down Expand Up @@ -311,7 +310,7 @@ private function addResourcesToMap(array &$map, array $resources, array $include
*
* If it is already present in the map, its properties will be merged into
* the existing array.
*
*
* @param array &$map
* @param ResourceInterface $resource
* @param Relationship[] $resource
Expand Down Expand Up @@ -397,9 +396,9 @@ private function indexRelationshipPaths(array $paths)

/**
* Get the fields that should be included for resources of the given type.
*
*
* @param string $type
*
*
* @return array|null
*/
private function getFieldsForType($type)
Expand Down
4 changes: 2 additions & 2 deletions src/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public function toArray()

/**
* Build an idenitfier array for the given resource.
*
*
* @param ResourceInterface $resource
*
*
* @return array
*/
private function buildIdentifier(ResourceInterface $resource)
Expand Down