Art4/json-api-client

IdentifierCollectionInterface should extend CollectionInterface

Closed this issue · 4 comments

I am building an extension to this library and to see if a resource's data contains an item or collection, I have to do this:

is_a($resource, IdentifierCollectionInterface::class) || is_a($resource, CollectionInterface::class);

They both extend AccessInterface, so this should have no affect on functionality

It seems I had an outdated version that had CollectionInterface instead of the more recently added ElementInterface, but the result should be the same

Art4 commented

The data attribute in the root Document cannot contain an IdentifierCollectionInterface. This would harm the JSON API spec. A collection in Document can only be a CollectionInterface, so you have to check only is_a($resource, CollectionInterface::class);

See the docs for possible values in Document: https://github.com/Art4/json-api-client/blob/master/docs/objects-document.md#properties

I understand. Thank you :)

Art4 commented

You're welcome. 😊