- Still WIP on Api's wrapper
This commit is contained in:
1 parent
1927b43999
commit
8e0dce3e71
6 files changed
+26
-6
No files matched your search
@@ -346,6 +346,18 @@ class EntityCollection extends \ArrayObject implements \JsonSerializable {
|
||||
return ( new $className() )->fromArray($dataset);
|
||||
}
|
||||
|
||||
public function arrayToEntities(array $list, ? string /*stringable*/ $entityClass = null) : self
|
||||
{
|
||||
$collection = new static();
|
||||
$collection->entityClass = $entityClass ?? $this->entityClass;
|
||||
|
||||
foreach($list as $dataset) {
|
||||
$collection->append($this->arrayToEntity($dataset, $entityClass));
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
|
||||
Reference in new issue
Block a user