Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
declare(strict_types=1);


use Infocyph\ArrayKit\Collection\Collection;

if (!function_exists('compare')) {
/**
* Compare two values using a specified operator.
Expand Down Expand Up @@ -57,7 +59,7 @@ function isCallable(mixed $value): bool
* @param mixed $default The default value to return if the key is not found.
* @return mixed The retrieved value(s).
*/
function array_get(array $array, int|string|array $key = null, mixed $default = null): mixed
function array_get(array $array, int|string|array|null $key = null, mixed $default = null): mixed
{
return Infocyph\ArrayKit\Array\DotNotation::get($array, $key, $default);
}
Expand All @@ -82,3 +84,15 @@ function array_set(array &$array, string|array|null $key, mixed $value = null, b
return Infocyph\ArrayKit\Array\DotNotation::set($array, $key, $value, $overwrite);
}
}
if (!function_exists('collect')) {
/**
* Wrap the given value in an {@see Collection}.
*
* @param mixed $data Anything “array-able”: array, Traversable, scalar, etc.
* @return Collection
*/
function collect(mixed $data = []): Collection
{
return Collection::make($data);
}
}