Like compose() but halts the chain and returns null if any callable produces a null value. Prevents passing null into callables that can't handle it.
/**
* @param callable(mixed):mixed ...$callables
* @return Closure(mixed):mixed
*/
GeneralFunctions\composeSafe(callable ...$callables): ClosureWhen GeneralFunctions\composeSafe() is called, it returns the following Closure which can be used like a regular function.
/**
* @param mixed $value
* @return mixed|null
*/
$function ($value)This can be used to create a simple closure which can be used as a regular function.
$nameOfAdmin = GeneralFunctions\composeSafe(
GeneralFunctions\getProperty('admin'),
GeneralFunctions\getProperty('name')
);
echo $nameOfAdmin(['admin' => ['name' => 'Ada']]); // 'Ada'
var_dump($nameOfAdmin(['admin' => null])); // NULL (chain halted)