fun-php
1.2
functional programming utilities for PHP
|
API Documentation | On Github | Functional programming with PHP |
Static Public Member Functions | |
static | filter (... $args) |
static | partition (... $args) |
static | each (... $args) |
static | map (... $args) |
static | flatMap (... $args) |
static | find (... $args) |
static | findIndex (... $args) |
static | some (... $args) |
static | every (... $args) |
static | sort (... $args) |
static | reverse (... $args) |
static | reduce (... $args) |
static | includes (... $args) |
static | prop (... $args) |
static | props (... $args) |
static | propOr (... $args) |
static | pick (... $args) |
static | uniq (... $args) |
static | uniqBy (... $args) |
static | splitAt (... $args) |
static | merge ($obj,... $objs) |
static | propEq (... $args) |
static | propSatisfies (... $args) |
static | pipe (... $fns) |
static | compose (... $fns) |
static | partial (... $args) |
static | not (... $args) |
Public Attributes | |
const | _ = '@@fun-php/placeholder' |
F::_ is a special placeholder value used to specify "gaps" within curried functions, allowing partial application of any combination of arguments, regardless of their positions. More... | |
This class contains all the methods of the fun-php library. These "methods" are all static, so these are just functions.
|
static |
Performs right-to-left function composition. Like the unix pipe (|), but reversed ! All the function must be unary.
callable | ...$fns |
|
static |
Iterate over an iterable, calling a provided function $fn for each element. Returns the original array.
callable | $fn | |
iterable | $arr |
|
static |
Takes a predicate and a iterable and returns true if all of the iterable members satisfies the predicate.
callable | $predicate | |
iterable | $arr |
|
static |
Takes a predicate and a iterable and returns an array containing the members of the given iterable which satisfy the given predicate.
callable | $predicate | |
iterable | $arr |
|
static |
Returns the first element of the list which matches the predicate, or null if no element matches.
T
callable | $predicate | |
iterable<T> | $arr |
|
static |
Returns the index of the first element of the list which matches the predicate, or null if no element matches.
callable | $predicate | |
iterable | $arr |
|
static |
Takes a function and a iterable, apply the function to each of the iterable value and then flatten the result.
callable | $fn | |
iterable | $arr |
|
static |
Takes a value and an array. Returns true if the value is in the array and false otherwise.
mixed | $needle | |
array | $haystack |
|
static |
Takes a function and a iterable and returns an array containing the results of function applied to each iterable values.
callable | $fn | |
iterable | $arr |
|
static |
Takes an (associative) array and at least one other (variadic on the second argument) and returns all these arrays merged together.
array | $array1 | |
array | ...$array2 |
|
static |
|
static |
Takes a function and an array of arguments. Applies the arguments to the function and returns a new function awaiting the rest of the arguments.
callable | $fn | |
array | $args |
|
static |
Takes a predicate and a list and returns the pair of elements which do and do not satisfy the predicate, respectively.
callable | $predicate | |
iterable | $arr |
|
static |
Takes a list of properties and an (associative) array. Returns a partial copy of the (associative) array containing only the keys specified.
array | $props | |
array | $array |
|
static |
Performs left-to-right function composition. Like the unix pipe (|). All the function must be unary.
callable | ...$fns |
|
static |
|
static |
Takes a property, a value and an (associative) array. Returns true if the specified array property is equal to the supplied value and false otherwise.
string | $prop | |
mixed | $value | |
array | $array |
|
static |
Takes a property, an array and a default value. Returns the array's property value if it exists and the default value otherwise.
string | int | $prop | |
mixed | $default | |
array | $array |
|
static |
Acts as multiple prop
array of keys in, array of values out. Preserves order.
array | $props | |
array | $array |
|
static |
Takes a predicate, a property and an (associative) array. Returns true if the specified array property matches the predicate and false otherwise.
callable | $predicate | |
mixed | $prop | |
array | $array |
|
static |
Takes an iterable, a function and a starting (or default) value. Reduces the iterable to a single value by successively calling the function, passing it an accumulator value and the current value from the iterable, and then passing the result to the next call.
callable | $fn | |
mixed | $arr | |
iterable | $arr |
|
static |
Takes an array (NO OBJECTS) and returns a reversed copy of the array.
array | $arr |
|
static |
Takes a predicate and a iterable and returns true if one of the iterable members satisfies the predicate.
callable | $predicate | |
iterable | $arr |
|
static |
Takes a comparison function and an array (NO OBJECTS) and return a copy of the array sorted according to the comparison function.
callable | $fn | |
array | $arr |
|
static |
Splits a given list at a given index.
int | $fn | |
array | $array |
|
static |
Takes an array and returns a new array containing only one copy of each element in the original one. Warning : re-indexes the array.
array | $array |
|
static |
Returns a new list containing only one copy of each element in the original list, based upon the value returned by applying the supplied function to each list element. Prefers the first item if the supplied function produces the same value on two items.
callable | $fn | |
array | $array |
const boehm_s\F::_ = '@@fun-php/placeholder' |