Data
abstract class Data implements IteratorAggregate, Countable (View source)
| internal | JSON:API maintains no PHP API. The API is the HTTP API. This class may change at any time and could break any dependencies on it. |
Represents the data and included objects of a top-level object.
Properties
| protected ResourceIdentifierInterface[] | $data | Various representations of JSON:API objects. |
|
| protected int | $cardinality | The number of resources permitted in this collection. |
|
| protected bool | $hasNextPage | Holds a boolean indicating if there is a next page. |
|
| protected int | $count | Holds the total count of entities. |
Methods
Instantiates a Data object.
Returns an iterator for entities.
Returns the number of entities.
{@inheritdoc}
{@inheritdoc}
Returns the collection as an array.
Checks if there is a next page in the collection.
Sets the has next page flag.
Gets the cardinality of this collection.
Details
__construct(array $data, int $cardinality = -1)
Instantiates a Data object.
ArrayIterator
getIterator()
Returns an iterator for entities.
int
count()
Returns the number of entities.
getTotalCount()
{@inheritdoc}
setTotalCount($count)
{@inheritdoc}
EntityInterface[]
toArray()
Returns the collection as an array.
bool
hasNextPage()
Checks if there is a next page in the collection.
setHasNextPage(bool $has_next_page)
Sets the has next page flag.
Once the collection query has been executed and we build the entity collection, we now if there will be a next page with extra entities.
int
getCardinality()
Gets the cardinality of this collection.
static Data
merge(Data $a, Data $b)
Returns a new Data object containing the entities of $this and $other.