3 ms·
Here's my version: function pipe($callables) { return array_reduce($callables, fn($carry, $callable) => call_user_func($callable, $carry)); }
by pdenton 5y ago
Here's my version:
function pipe($callables) {
return array_reduce($callables, fn($carry, $callable) => call_user_func($callable, $carry));
}
Whenever a method merely calls other methods in sequence, returning the result of the last call, it's just too easy for me to simply use a pipe function. I guess it's mostly a matter of preference.