Skip to content

Commit

Permalink
feat: add getArray to std collection
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed May 11, 2022
1 parent a7048ea commit 3c0bfc6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Std/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,19 @@ public function getString(string $key, string $default = ''): string
return $default;
}

/**
* @param string $key
* @param array $default
*
* @return array
*/
public function getArray(string $key, array $default = []): array
{
$data = $this->get($key);

return $data ? (array)$data : $default;
}

/**
* Add item to collection
*
Expand Down

0 comments on commit 3c0bfc6

Please sign in to comment.