Stars: 333
Forks: 45
Pull Requests: 90
Issues: 5
Watchers: 21
Last Updated: 2022-01-25 09:38:00
⚡️ λ PHP functional library focused on simplicity and performance
License: MIT License
Languages: PHP
Phunctional, because functional programming matters.
Lambdish's Phunctional is a little library that tries to bring to PHP some aspects of functional programing with util high order functions and functions for manage iterables.
Phunctional is heavily inspired by Clojure and some other PHP libraries like iter, compose and felpado.
The main principles that we have in mind developing this library are:
All of this can be resumed with a word: Immutability.
To install it with composer:
composer require lambdish/phunctional
The first is to import every function you're going to use, for example:
use function Lambdish\phunctional\map;
And then you'll be able to use it:
map(
function ($number) {
return $number + 10;
},
[1, 2, 3, 4, 5]
);
// => [11, 12, 13, 14, 15]
And do something more complex like:
use function Lambdish\Phunctional\pipe;
use const Lambdish\Phunctional\{filter_null, reverse, first};
$lastNonNullableValue = pipe(filter_null, reverse, first);
$lastNonNullableValue(['first', null, 'other', 'last non nullable', null, null]);
// => "last non nullable"
Here we're using the provided constants, that acts like an alias for the functions full qualified namespace
(and therefore, are callable
).
You can find the functions documentation here.