Functional Programming Helpers and Data Types for PHP.
composer require mckayb/phantasy
use Phantasy\DataTypes\Maybe\Maybe;
use function Phantasy\Core\prop;
$user = [ "name" => "Foo", "email" => "[email protected]" ];
$name = Maybe::of($user)
->map(prop('name'))
->getOrElse(null);
// "Foo"
For more information, read the docs!
- Currying, Composition, Higher-Order Functions, etc
- Maybe, Either, Reader, Writer, State, Linked List, Validation Data Types.
- More coming...
Find a bug? Want to make any additions? Just create an issue or open up a pull request.
For other helpers not included in this repo, check out