Skip to content

Commit 81dc06d

Browse files
committed
up: collection add new method: getSub
1 parent a9ea8f4 commit 81dc06d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Std/Collection.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,21 @@ public function mapObject(string $key, string|object $obj): object
201201
if ($data = $this->getArray($key)) {
202202
Php::initObject($obj, $data);
203203
}
204-
205204
return $obj;
206205
}
207206

207+
/**
208+
* Get data as sub collection
209+
*
210+
* @param string $key
211+
*
212+
* @return static
213+
*/
214+
public function getSub(string $key): static
215+
{
216+
return static::new($this->getArray($key));
217+
}
218+
208219
/**
209220
* Add item to collection
210221
*

0 commit comments

Comments
 (0)