Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kocsismate committed Mar 4, 2019
1 parent c4e6617 commit d4977c5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ you to implement the following methods:
*
* The method returns a new JsonApiObject object if this member should be present or null
* if it should be omitted from the response.
*
* @return JsonApiObject|null
*/
public function getJsonApi(): ?JsonApiObject
{
Expand Down Expand Up @@ -333,6 +331,12 @@ class BookResource extends AbstractResource
* @var PublisherResource
*/
private $publisherResource;

/**
* You can type-hint the object property this way.
* @var array
*/
protected $object;

public function __construct(
AuthorResource $authorResource,
Expand Down Expand Up @@ -365,7 +369,7 @@ class BookResource extends AbstractResource
{
return $this->object["id"];

// This is equivalent to the following:
// This is equivalent to the following (the $book parameter is used this time instead of $this->object):
return $book["id"];
}

Expand Down Expand Up @@ -419,7 +423,7 @@ class BookResource extends AbstractResource
},
];

// This is equivalent to the following:
// This is equivalent to the following (the $book parameter is used this time instead of $this->object):
return [
"title" => function (array $book) {
return $book["title"];
Expand Down Expand Up @@ -469,7 +473,7 @@ class BookResource extends AbstractResource
},
];

// This is equivalent to the following:
// This is equivalent to the following (the $book parameter is used this time instead of $this->object):

return [
"authors" => function (array $book) {
Expand All @@ -491,8 +495,8 @@ class BookResource extends AbstractResource
}
```

Generally, you don't use resources directly. Only documents need them to be able to fill the "data",
the "included" and the "relationship" members in the responses.
Generally, you don't use resources directly. Only documents need them to be able to fill the "data", the "included",
and the "relationship" members in the responses.

### Hydrators

Expand Down

0 comments on commit d4977c5

Please sign in to comment.