Skip to content

Commit 3c0bfc6

Browse files
committed
feat: add getArray to std collection
1 parent a7048ea commit 3c0bfc6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Std/Collection.php

+13
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,19 @@ public function getString(string $key, string $default = ''): string
158158
return $default;
159159
}
160160

161+
/**
162+
* @param string $key
163+
* @param array $default
164+
*
165+
* @return array
166+
*/
167+
public function getArray(string $key, array $default = []): array
168+
{
169+
$data = $this->get($key);
170+
171+
return $data ? (array)$data : $default;
172+
}
173+
161174
/**
162175
* Add item to collection
163176
*

0 commit comments

Comments
 (0)