nicl / functional-php

a collection of composable functions inspired by Clojure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

functional-php

success-kid-php

A collection of utility functions, inspired (mostly) by Clojure. A few are simply wrappers around existing PHP functions. For the most part, however, they offer something new. Some functions which appear familiar add value by accepting a variable number of arguments (for example, max, or merge).

Functions included

Note, none of this is fully decided yet; more functions may be included, others may be removed. Nobody knows what's going to happen - it's crazy!!!

  • and_all
  • apply
  • assoc
  • comp
  • compare
  • complement
  • concat
  • contains
  • dissoc
  • distinct
  • drop
  • every
  • every_pred
  • filter
  • flatten
  • group_by
  • interleave
  • interpose
  • iterate
  • keep
  • map
  • mapcat
  • map_indexed
  • max
  • memoize
  • merge
  • merge_with
  • min
  • nth
  • partial
  • partition
  • partition_all
  • partition_by
  • reduce
  • reify (?)
  • rem
  • reverse
  • set
  • some
  • split_at
  • split_with
  • take
  • take_last
  • take_nth
  • take_while
  • unless
  • update_in
  • zipmap

Tests

Functional-PHP needs better tests! All pull requests to improve or add new tests are welcome.

If you wish to run the tests you need to have PHPUnit installed. Then, from the functional-php root directory run:

phpunit

(You may need to adapt the phpunit command and paths depending on your configuration.)

About

a collection of composable functions inspired by Clojure

License:MIT License


Languages

Language:PHP 100.0%