aeris / fn
There is no license information available for the latest version (v1.4.0) of this package.
Functional utility library
v1.4.0
2015-08-20 19:04 UTC
Requires
- aeris/spy: ^1.1.0
This package is not auto-updated.
Last update: 2024-11-17 07:27:45 UTC
README
Functional utility library for PHP.
API
partial
compose
identity
constant
always
never
cat
moreThanOrEqualTo
lessthan
equalTo
notEqualTo
even
odd
both
invoker
invokeAll
invoke
negate
conditional
doWhen
errorThrower
conditionalThrower
throwWhen
throwError
resolve
resolver
whenSetInvoker
keySetChecker
isKeySet
accessor
cb
zip
mapAssoc
pick
pluck
Plucks a property from a collection of associative arrays.
eg:
Fn\pluck([ ['name' => 'moe', 'age' => 45], ['name' => 'larry', 'age' => 55], ['name' => 'curly', 'age' => 65] ], 'name'); // --> ['moe', 'larry', 'curly']
concat
Add a value to an array, or merge a set of values.
Fn\concat(['a', 'b'], 'c'); // ['a', 'b', 'c'] Fn\concat(['a', 'b'], ['c', 'd']); // ['a', 'b', 'c', 'd']
any
Returns true if any item in the array passes a predicate
Example:
Fn\any([1, 3, 4, 5, 9], Fn\even()) // true Fn\any([1, 3, 5, 9], Fn\even()) // false
all
Returns true if every item in the array passes a predicate
Example:
Fn\all([1, 3, 5, 9], Fn\odd()) // true Fn\all([1, 3, 4, 5, 9], Fn\even()) // false
joinOr
joinAnd
factoryMap
factory
caller
countWhere
reduceAssoc
times
Invoke a callable some number of times.
Fn\times(3, function($i) { echo "call #$i"; }) // call 1 // call 2 // call 3