Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Lines changed: 12 additions & 1 deletion
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)

AltStyle によって変換されたページ (->オリジナル) /