Fork me on GitHub
fun-php  1.2
functional programming utilities for PHP
API Documentation On Github Functional programming with PHP
fun-php

fun-php

Build Status
codecov

A practical functional library for PHP programmers.

What is it ?

Why ?

Installation and Usage

Install the library using composer :

composer require boehm_s/fun

And then, import it in your files :

Everything's up and running, you can play with it !

$greetings = ['hello', 'world', '!'],
$yellList = F::compose(
F::partial('implode', [' ']),
F::map('strtoupper')
);
$yellList($greetings); // "HELLO WORLD !"

Philosophy

Using fun-php should be as painless as possible : no weird syntax, no OOP syntax, just functions (everywhere) !

As with Ramda, all the functions are automatically curried, and data comes last so you can easely compose them. Also, placeholders are implemented ! It means that the followings are equivalent :

// F::_ is the placeholder
F::map('strtoupper', ['hello', 'world', '!']);
F::map('strtoupper')(['hello', 'world', '!']);
F::map(F::_, ['hello', 'world', '!'])('strtoupper');

Documentation

Please review the API documentation

Running the test suite

To run the test suite, you'll need composer to be installed.

Then, install the dependencies (phpunit) :

composer install

And run the test :

composer test