feature: support head() and last()

This commit is contained in:
Claas Augner 2021-07-05 11:35:03 +02:00
parent 0369da4a30
commit 1e7bbf8ee1

View File

@ -81,6 +81,32 @@ class NullObject {
}
}
/**
* Get the first element of an array. Useful for method chaining.
*
* @template TValue
* @template TParam of TValue[]
* @param TParam $array
* @return (TParam is non-empty-array ? TValue : false)
*/
function head($array)
{
return reset($array);
}
/**
* Get the last element from an array.
*
* @template TValue
* @template TParam of TValue[]
* @param TParam $array
* @return (TParam is non-empty-array ? TValue : false)
*/
function last($array)
{
}
/**
* Provide access to optional objects.
*