protected function getRelationshipHydrator($book): array
    {
        return [
            "authors" => function (array $book, ToManyRelationship $authors, $data, $relationshipName) {
                if ($authors->isEmpty()) {
                    $book["authors"] = [];
                } else {
                    $book["authors"] = BookRepository::getAuthors($authors->getResourceIdentifierIds());
                }

                return $book;
            },
            "publisher" => function (array &$book, ToOneRelationship $publisher, $data, $relationshipName) {
                if ($publisher->isEmpty()) {
                    $book["publisher"] = null;
                } else {
                    $book["publisher"] = BookRepository::getPublisher((int) $publisher->getResourceIdentifier()->getId());
                }
            }
        ];
    }
protected function getRelationshipHydrator($book): array
    {
        return [
            "authors" => function (array $book, ToManyRelationship $authors, $data, $relationshipName) {
                if ($authors->isEmpty()) {
                    $book["authors"] = [];
                } else {
                    $book["authors"] = BookRepository::getAuthors($authors->getResourceIdentifierIds());
                }

                return $book;
            },
            "publisher" => function (array &$book, ToOneRelationship $publisher, $data, $relationshipName) {
                if ($publisher->isEmpty()) {
                    $book["publisher"] = null;
                } else {
                    $book["publisher"] = BookRepository::getPublisher((int) $publisher->getResourceIdentifier()->getId());
                }
            }
        ];
    }
protected function getRelationshipHydrator ( $ book ) : array { return [ "authors" => function ( array $ book , ToManyRelationship $ authors , $ data , $ relationshipName ) { if ( $ authors -> isEmpty ( ) ) { $ book [ "authors" ] = [ ] ; } else { $ book [ "authors" ] = BookRepository :: getAuthors ( $ authors -> getResourceIdentifierIds ( ) ) ; } return $ book ; } , "publisher" => function ( array & $ book , ToOneRelationship $ publisher , $ data , $ relationshipName ) { if ( $ publisher -> isEmpty ( ) ) { $ book [ "publisher" ] = null ; } else { $ book [ "publisher" ] = BookRepository :: getPublisher ( ( int ) $ publisher -> getResourceIdentifier ( ) -> getId ( ) ) ; } } ] ; }
Provides the relationship hydrators.

The method returns an array of relationship hydrators, where a hydrator is a key-value pair:
the key is the specific relationship name which comes from the request and the value is a
callable which hydrate the previous relationship.
These callables receive the domain object (which will be hydrated), an object representing the
currently processed relationship (it can be a ToOneRelationship or a ToManyRelationship
object), the "data" part of the request and the relationship name as their arguments, and
they should mutate the state of the domain object.
If it is an immutable object or an array (and passing by reference isn't used),
the callable should return the domain object.

@param array $book
@return callable[]
Provides the relationship hydrators .