public function __construct(array
$data,
$cardinality = -1
) { assert(Inspector::
assertAllObjects($data, ResourceIdentifierInterface::
class));
assert($cardinality >= -1 &&
$cardinality !== 0, 'Cardinality must be -1 for unlimited cardinality or a positive integer.'
);
assert($cardinality === -1 ||
count($data) <=
$cardinality, 'If cardinality is not unlimited, the number of given resources must not exceed the cardinality of the collection.'
);
$this->data =
array_values($data);
$this->cardinality =
$cardinality;
} /**
* Returns an iterator for entities.
*
* @return \ArrayIterator
* An \ArrayIterator instance
*/