PHPackages                             miroshnikov/idles - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. miroshnikov/idles

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

miroshnikov/idles
=================

A PHP functional utility library, port of Lodash/Ramda with lazy (idle) evaluation

2.14.0(2mo ago)151943MITPHPPHP &gt;=8.4CI passing

Since Feb 9Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/miroshnikov/idles)[ Packagist](https://packagist.org/packages/miroshnikov/idles)[ Docs](https://miroshnikov.github.io/idles/)[ RSS](/packages/miroshnikov-idles/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (20)Versions (35)Used By (0)

 [ ![](https://github.com/miroshnikov/idles/raw/main/docs/assets/logo.png) ](https://idlephp.tech)

IDLES - a PHP functional library
================================

[](#idles---a-php-functional-library)

A PHP functional utility library, port of Javascript Lodash/Fp and Ramda libraries to PHP.

All functions are **side-effect free** and **automatically curried**, data is **immutable**.

The iterable collection parameter is usually supplied last to make currying convenient.

**Lazy / delayed evaluation** is supported in functional pipelines.

Go to **** for more details, documentation and examples.

Requirements
------------

[](#requirements)

`PHP 8.4` or higher

Installation
------------

[](#installation)

`composer require miroshnikov/idles`

Roadmap
-------

[](#roadmap)

Note

Idles is currently under active development. Roadmap is to add all methods from Lodash and Ramda libraries and some functional tools.

Documentation
-------------

[](#documentation)

### [add](https://idlephp.tech/#add)

[](#add)

```
add($a, $b)
```

Calculates the sum of two numbers.

### [adjust](https://idlephp.tech/#adjust)

[](#adjust)

```
adjust($key, $fn, $collection)
```

Applies a function to the value at the given key of an array.

### [all](https://idlephp.tech/#all)

[](#all)

```
all($predicate, $collection)
```

Checks if `$predicate` returns truthy for **all** elements of `$collection`. Stop once it returns falsey.

### [allPass](https://idlephp.tech/#allPass)

[](#allpass)

```
allPass($predicates)
```

Returns a function that checks if its arguments pass all `$predicates`.

### [always](https://idlephp.tech/#always)

[](#always)

```
always($value)
```

Returns a function that always returns the given value.

### [any](https://idlephp.tech/#any)

[](#any)

```
any($predicate, $collection)
```

Checks if `$predicate` returns truthy for **any** element of `$collection`. Stops on first found.

### [anyPass](https://idlephp.tech/#anyPass)

[](#anypass)

```
anyPass($predicates)
```

Returns a function that checks if its arguments pass any of the `$predicates`.

### [apply](https://idlephp.tech/#apply)

[](#apply)

```
apply($fn, $args)
```

Calls $fn(...$args).

### [applyTo](https://idlephp.tech/#applyTo)

[](#applyto)

```
applyTo($value, $interceptor)
```

Returns the result of `$interceptor($value)`.

### [ary](https://idlephp.tech/#ary)

[](#ary)

```
ary($n, $fn)
```

Creates a function that invokes `$fn`, with up to `$n` arguments, ignoring any additional arguments.

### [ascend](https://idlephp.tech/#ascend)

[](#ascend)

```
ascend($fn, $a, $b)
```

Makes an ascending comparator function out of a function that returns a value that can be compared with ``.

### [attempt](https://idlephp.tech/#attempt)

[](#attempt)

```
attempt($fn, $args)
```

Calls `$fn`, returning either the result or the caught exception.

### [both](https://idlephp.tech/#both)

[](#both)

```
both($fn1, $fn2)
```

Resulting function returns `$fn1(...$args)` if it is falsy or `$fn2(...$args)` otherwise, short-circuited.

### [call](https://idlephp.tech/#call)

[](#call)

```
call($fn, ...$args)
```

Calls $fn(...$args).

### [camelCase](https://idlephp.tech/#camelCase)

[](#camelcase)

```
camelCase($string)
```

Converts string to camel case.

### [capitalize](https://idlephp.tech/#capitalize)

[](#capitalize)

```
capitalize($string)
```

Converts the first character of string to upper case and the remaining to lower case.

### [collect](https://idlephp.tech/#collect)

[](#collect)

```
collect($collection)
```

Collects any iterable into array

### [compose](https://idlephp.tech/#compose)

[](#compose)

```
compose(...$fns)
```

Like `pipe` but invokes the functions from right to left.

### [concat](https://idlephp.tech/#concat)

[](#concat)

```
concat($first, $second)
```

Concatinates an iterable with an iterable/value.

### [concatAll](https://idlephp.tech/#concatAll)

[](#concatall)

```
concatAll($values)
```

Concatinates an iterable with additional iterables/values

### [cond](https://idlephp.tech/#cond)

[](#cond)

```
cond($pairs)
```

Iterates over `$pairs` and invokes the corresponding function of the first predicate to return truthy.

### [converge](https://idlephp.tech/#converge)

[](#converge)

```
converge($afterFn, $functions)
```

Resulting function will call each function with input arguments and pass results to `$afterFn`.

### [count](https://idlephp.tech/#count)

[](#count)

```
count($predicate, $collection)
```

Counts the number of items in `$collection` matching the `$predicate`

### [countBy](https://idlephp.tech/#countBy)

[](#countby)

```
countBy($iteratee, $collection)
```

Returns an `array`

### [curry](https://idlephp.tech/#curry)

[](#curry)

```
curry($fn)
```

`\Idles\_` const may be used as a placeholder.

### [curryN](https://idlephp.tech/#curryN)

[](#curryn)

```
curryN($arity, $fn)
```

Curry with fixed arity. `\Idles\_` const may be used as a placeholder.

### [curryRight](https://idlephp.tech/#curryRight)

[](#curryright)

```
curryRight($f)
```

Like `curry` but arguments are prepended.

### [curryRightN](https://idlephp.tech/#curryRightN)

[](#curryrightn)

```
curryRightN($arity, $f)
```

Like `curryN` but arguments are prepended.

### [dec](https://idlephp.tech/#dec)

[](#dec)

```
dec($number)
```

Returns $number - 1

### [defaultTo](https://idlephp.tech/#defaultTo)

[](#defaultto)

```
defaultTo($default, $value)
```

Returns `$value` if it is truthy, otherwise `$default`.

### [descend](https://idlephp.tech/#descend)

[](#descend)

```
descend($fn, $a, $b)
```

Makes an descending comparator function out of a function that returns a value that can be compared with &lt;=&gt;.

### [divide](https://idlephp.tech/#divide)

[](#divide)

```
divide($a, $b)
```

Returns $a / $b

### [drop](https://idlephp.tech/#drop)

[](#drop)

```
drop($n, $collection)
```

Skips the first `$n` elemens and returns the rest of iterable or string.

### [dropLast](https://idlephp.tech/#dropLast)

[](#droplast)

```
dropLast($n, $collection)
```

Skips the last `$n` elements of iterable or string.

### [each](https://idlephp.tech/#each)

[](#each)

```
each($iteratee, $collection)
```

Iterates over elements of `$collection`. Iteratee may exit iteration early by returning `false`.

### [either](https://idlephp.tech/#either)

[](#either)

```
either($fn1, $fn2)
```

Resulting function returns `$fn1(...$args)` if it is truthy or `$fn2(...$args)` otherwise, short-circuited.

### [eq](https://idlephp.tech/#eq)

[](#eq)

```
eq($a, $b)
```

`$a == $b`

### [equals](https://idlephp.tech/#equals)

[](#equals)

```
equals($a, $b)
```

`$a === $b`

### [escapeRegExp](https://idlephp.tech/#escapeRegExp)

[](#escaperegexp)

```
escapeRegExp($string)
```

Escapes regular expression.

### [evolve](https://idlephp.tech/#evolve)

[](#evolve)

```
evolve($transformations, $record)
```

Creates a new record by recursively calling transformation functions with `$record` properties.

### [F](https://idlephp.tech/#F)

[](#f)

```
F(...$args)
```

Always returns `false`

### [filter](https://idlephp.tech/#filter)

[](#filter)

```
filter($predicate, $collection)
```

Returns elements `$predicate` returns truthy for.

### [find](https://idlephp.tech/#find)

[](#find)

```
find($predicate, $collection)
```

Returns the first element `$predicate` returns truthy for.

### [findFrom](https://idlephp.tech/#findFrom)

[](#findfrom)

```
findFrom($predicate, $fromIndex, $collection)
```

Returns the first element `$predicate` returns truthy for starting from `$fromIndex`.

### [findIndex](https://idlephp.tech/#findIndex)

[](#findindex)

```
findIndex($predicate, $collection)
```

Returns the index of the first element predicate returns truthy for or `-1` if not found.

### [findIndexFrom](https://idlephp.tech/#findIndexFrom)

[](#findindexfrom)

```
findIndexFrom($predicate, $fromIndex, $collection)
```

Returns the index of the first element `$predicate` returns truthy for starting from `$fromIndex`.

### [findLastIndex](https://idlephp.tech/#findLastIndex)

[](#findlastindex)

```
findLastIndex($predicate, $collection)
```

Returns the index of the last element predicate returns truthy for, -1 if not found.

### [findLastIndexFrom](https://idlephp.tech/#findLastIndexFrom)

[](#findlastindexfrom)

```
findLastIndexFrom($predicate, $fromIndex, $collection)
```

Returns the index of the last element `$predicate` returns truthy for starting from `$fromIndex`.

### [flatMap](https://idlephp.tech/#flatMap)

[](#flatmap)

```
flatMap($iteratee, $collection)
```

Maps and flattens.

### [flatMapDepth](https://idlephp.tech/#flatMapDepth)

[](#flatmapdepth)

```
flatMapDepth($iteratee, $depth, $collection)
```

Maps and flattens the mapped results up to `$depth` times.

### [flatten](https://idlephp.tech/#flatten)

[](#flatten)

```
flatten($collection)
```

Flattens iterable a single level deep.

### [flattenDepth](https://idlephp.tech/#flattenDepth)

[](#flattendepth)

```
flattenDepth($depth, $collection)
```

Recursively flatten array up to `$depth` times.

### [flip](https://idlephp.tech/#flip)

[](#flip)

```
flip($fn)
```

Returns a new curried function with the first two arguments reversed.

### [flow](https://idlephp.tech/#flow)

[](#flow)

```
flow($funcs)
```

Left-to-right function composition. The first argument may have any arity; the remaining arguments must be unary.

### [fromPairs](https://idlephp.tech/#fromPairs)

[](#frompairs)

```
fromPairs($collection)
```

Creates a new record from a list key-value pairs. The inverse of `toPairs`.

### [groupBy](https://idlephp.tech/#groupBy)

[](#groupby)

```
groupBy($iteratee, $collection)
```

Creates an array composed of keys generated from running each value through `$iteratee`.

### [gt](https://idlephp.tech/#gt)

[](#gt)

```
gt($a, $b)
```

$a &gt; $b

### [gte](https://idlephp.tech/#gte)

[](#gte)

```
gte($a, $b)
```

$a &gt;= $b

### [has](https://idlephp.tech/#has)

[](#has)

```
has($key, $record)
```

Checks if `$record` has `$key` by calling `array_key_exists()`.

### [hasPath](https://idlephp.tech/#hasPath)

[](#haspath)

```
hasPath($path, $record)
```

Checks if `$path` exists in `$record`.

### [head](https://idlephp.tech/#head)

[](#head)

```
head($collecton)
```

Gets the first element of `$collecton`.

### [identity](https://idlephp.tech/#identity)

[](#identity)

```
identity($value)
```

Returns the first argument it receives.

### [ifElse](https://idlephp.tech/#ifElse)

[](#ifelse)

```
ifElse($predicate, $onTrue, $onFalse)
```

Resulting function returns `$onTrue(...$args)` if `$predicate(...$args)` is truthy or `$onFalse(...$args)` otherwise.

### [inc](https://idlephp.tech/#inc)

[](#inc)

```
inc($number)
```

Returns `$number + 1`

### [includes](https://idlephp.tech/#includes)

[](#includes)

```
includes($value, $collection)
```

Checks if `$value` is in iterable/string.

### [includesFrom](https://idlephp.tech/#includesFrom)

[](#includesfrom)

```
includesFrom($value, $fromIndex, $collection)
```

Checks if `$value` is in iterable/string, starting from `$fromIndex`.

### [indexBy](https://idlephp.tech/#indexBy)

[](#indexby)

```
indexBy($iteratee, $collection)
```

Creates a record composed of keys generated from the results of running each element of $collection through $iteratee.

### [indexOf](https://idlephp.tech/#indexOf)

[](#indexof)

```
indexOf($item, $collection)
```

Returns the index of the first occurrence of the item in an iterable or string, else `-1`.

### [indexOfFrom](https://idlephp.tech/#indexOfFrom)

[](#indexoffrom)

```
indexOfFrom($item, $fromIndex, $collection)
```

Returns the index of the first occurrence of the item in an iterable or string, starting from `$fromIndex`, else `-1`.

### [insert](https://idlephp.tech/#insert)

[](#insert)

```
insert($index, $element, $array)
```

Inserts the `$element` at the specified `$index`.

### [intersection](https://idlephp.tech/#intersection)

[](#intersection)

```
intersection($array1, $array2)
```

Returns unique values that are included in both arrays.

### [intersectionBy](https://idlephp.tech/#intersectionBy)

[](#intersectionby)

```
intersectionBy($iteratee, $array1, $array2)
```

Like intersection but invokes `$iteratee` for each element before comparison.

### [intersectionWith](https://idlephp.tech/#intersectionWith)

[](#intersectionwith)

```
intersectionWith($comparator, $array1, $array2)
```

Like `intersection` but invokes `$comparator` to compare elements.

### [invert](https://idlephp.tech/#invert)

[](#invert)

```
invert($collection)
```

Replaces keys with values. Duplicate keys are overwritten.

### [isEmpty](https://idlephp.tech/#isEmpty)

[](#isempty)

```
isEmpty($value)
```

Returns result of `empty($value)`.

### [isNotEmpty](https://idlephp.tech/#isNotEmpty)

[](#isnotempty)

```
isNotEmpty($value)
```

Returns result of `!empty($value)`.

### [iterate](https://idlephp.tech/#iterate)

[](#iterate)

```
iterate($fn, $value)
```

Returns a generator of `$value`, `$f($value)`, `$f($f($value))` etc.

### [join](https://idlephp.tech/#join)

[](#join)

```
join($separator, $collection)
```

Joins iterable elements separated by `$separator`.

### [just](https://idlephp.tech/#just)

[](#just)

```
just($value)
```

Returns an Optional with the specified non-null value

### [juxt](https://idlephp.tech/#juxt)

[](#juxt)

```
juxt($iteratees)
```

Applies a list of functions to a list of values.

### [kebabCase](https://idlephp.tech/#kebabCase)

[](#kebabcase)

```
kebabCase($string)
```

Converts `string` to kebab case.

### [keys](https://idlephp.tech/#keys)

[](#keys)

```
keys($record)
```

Returns an indexed iterable of keys in `$record`.

### [last](https://idlephp.tech/#last)

[](#last)

```
last($collecton)
```

Gets the last element of iterable.

### [lastIndexOf](https://idlephp.tech/#lastIndexOf)

[](#lastindexof)

```
lastIndexOf($item, $collection)
```

Returns the index of the last occurrence of `$value` in iterable or string, else `-1`.

### [length](https://idlephp.tech/#length)

[](#length)

```
length($value)
```

Returns size of a countable, number of parameters of a function, lenght of string or number of properties of an object.

### [lowerFirst](https://idlephp.tech/#lowerFirst)

[](#lowerfirst)

```
lowerFirst($string)
```

Converts the first character of string to lower case.

### [lt](https://idlephp.tech/#lt)

[](#lt)

```
lt($a, $b)
```

$a &lt; $b

### [lte](https://idlephp.tech/#lte)

[](#lte)

```
lte($a, $b)
```

$a &lt;= $b

### [map](https://idlephp.tech/#map)

[](#map)

```
map($iteratee, $collection)
```

Run each element in `$collection` through `$iteratee`.

### [mapKeys](https://idlephp.tech/#mapKeys)

[](#mapkeys)

```
mapKeys($iteratee, $collection)
```

Transforms an object by converting the keys to new values.

### [memoize](https://idlephp.tech/#memoize)

[](#memoize)

```
memoize($fn)
```

Creates a function that memoizes the result of `$fn`.

### [memoizeWith](https://idlephp.tech/#memoizeWith)

[](#memoizewith)

```
memoizeWith($resolver, $fn)
```

Creates a function that memoizes the result of `$fn`. `$resolver` returns map cache key (args\[0\] by default).

### [merge](https://idlephp.tech/#merge)

[](#merge)

```
merge($left, $right)
```

Merges properties, numeric keys are **replaced**.

### [mergeAll](https://idlephp.tech/#mergeAll)

[](#mergeall)

```
mergeAll($iterables)
```

Merges properties, numeric keys are **replaced**.

### [mergeDeep](https://idlephp.tech/#mergeDeep)

[](#mergedeep)

```
mergeDeep($left, $right)
```

Merges properties recursively, numeric keys are **replaced**.

### [mergeWith](https://idlephp.tech/#mergeWith)

[](#mergewith)

```
mergeWith($customizer, $left, $right)
```

Like `merge` but if a key exists in both records, `$customizer` is called to the values associated with the key.

### [modifyPath](https://idlephp.tech/#modifyPath)

[](#modifypath)

```
modifyPath($path, $updater, $record)
```

Creates new record by applying an `$updater` function to the value at the given `$path`.

### [modulo](https://idlephp.tech/#modulo)

[](#modulo)

```
modulo($a, $b)
```

$a % $b

### [multiply](https://idlephp.tech/#multiply)

[](#multiply)

```
multiply($a, $b)
```

$a \* $b

### [negate](https://idlephp.tech/#negate)

[](#negate)

```
negate($predicate)
```

Creates a function that negates the result of the `$predicate` function.

### [not](https://idlephp.tech/#not)

[](#not)

```
not($a)
```

returns !$a

### [nothing](https://idlephp.tech/#nothing)

[](#nothing)

```
nothing()
```

Returns an empty `Optional`.

### [now](https://idlephp.tech/#now)

[](#now)

```
now()
```

Returns the timestamp of the number of seconds

### [nth](https://idlephp.tech/#nth)

[](#nth)

```
nth($offset, $collection)
```

Returns the `$offset` element. If `$offset` is negative the element at index length + `$offset` is returned.

### [nthArg](https://idlephp.tech/#nthArg)

[](#ntharg)

```
nthArg($n)
```

Returns a function which returns its `$nth` argument.

### [objOf](https://idlephp.tech/#objOf)

[](#objof)

```
objOf($key, $value)
```

Creates an array containing a single `key => value` pair.

### [omit](https://idlephp.tech/#omit)

[](#omit)

```
omit($keys, $collection)
```

The opposite of `pick`. Returns record without `$keys`.

### [omitBy](https://idlephp.tech/#omitBy)

[](#omitby)

```
omitBy($predicate, $collection)
```

The opposite of `pickBy`. Returns properties of `$record` that $predicate returns `falsey` for.

### [once](https://idlephp.tech/#once)

[](#once)

```
once($fn)
```

`$fn` is only called once, the first value is returned in subsequent invocations.

### [Optional](https://idlephp.tech/#Optional)

[](#optional)

```
interface Optional
{
    /**
     * @return bool true if not empty
     */
    public function isPresent(): bool;
    /**
     * @return bool true if empty
     */
    public function isEmpty(): bool;
    /**
     * Returns value, throw exception if empty
     */
    public function get(): mixed;
    /**
     * Returns the contained value if the optional is nonempty or `$default`
     */
    public function orElse(mixed $default): mixed;
    /**
     * Returns the contained value, if present, otherwise throw an exception
     */
    public function orElseThrow(\Exception $e = new \Exception('No value on None')): mixed;
    /**
     * If a value is present, apply the `$fn` to it, and if the result is non-null, return an Optional describing the result
     */
    public function map(callable $fn): Optional;
    /**
     * Use instead of map if $f returns Optional
     */
    public function flatMap(callable $fn): Optional;
    /**
     * If a value is present and matches the `$predicate`, return an Optional with the value, otherwise an empty Optional.
     */
    public function filter(callable $predicate): Optional;
}
```

Maybe/Option monad (container) which may or may not contain a non-null value.

### [orderBy](https://idlephp.tech/#orderBy)

[](#orderby)

```
orderBy($iteratees, $orders, $collection)
```

Like `sortBy` but allows specifying the sort orders.

### [pad](https://idlephp.tech/#pad)

[](#pad)

```
pad($padChars, $length, $string)
```

Pad a string on the left and right sides to a certain length with padding characters.

### [padEnd](https://idlephp.tech/#padEnd)

[](#padend)

```
padEnd($padChars, $length, $string)
```

Pad a string on the right side to a certain length with padding characters.

### [padStart](https://idlephp.tech/#padStart)

[](#padstart)

```
padStart($padChars, $length, $string)
```

Pad a string on the left side to a certain length with padding characters.

### [partial](https://idlephp.tech/#partial)

[](#partial)

```
partial($fn, $partials)
```

Creates a function that invokes `$fn` with `$partials` prepended to the arguments. `\Idles\_` const may be used as a placeholder.

### [partialRight](https://idlephp.tech/#partialRight)

[](#partialright)

```
partialRight($fn, $partials)
```

Like partial but `$partials` are **appended**.

### [partition](https://idlephp.tech/#partition)

[](#partition)

```
partition($predicate, $collection)
```

Split `$collection` into two groups, the first of which contains elements `$predicate` returns truthy for, the second of which contains elements `$predicate` returns falsey for.

### [path](https://idlephp.tech/#path)

[](#path)

```
path($path, $collection)
```

Retrieve the value at a given path.

### [pathEq](https://idlephp.tech/#pathEq)

[](#patheq)

```
pathEq($value, $path, $record)
```

If a record has a `$value` at `$path` in `equals()` terms.

### [pathOr](https://idlephp.tech/#pathOr)

[](#pathor)

```
pathOr($default, $path, $collection)
```

Retrieve the value at a given path. If path is not found, the `$default` is returned.

### [paths](https://idlephp.tech/#paths)

[](#paths)

```
paths($paths, $collection)
```

Keys in, values out. Order is preserved.

### [pick](https://idlephp.tech/#pick)

[](#pick)

```
pick($keys, $collection)
```

Returns record containing only `$keys`.

### [pickBy](https://idlephp.tech/#pickBy)

[](#pickby)

```
pickBy($predicate, $collection)
```

Returns record containing only keys $predicate returns truthy for.

### [pipe](https://idlephp.tech/#pipe)

[](#pipe)

```
pipe(...$fns)
```

Left-to-right function composition. The first argument may have any arity; the remaining arguments must be unary.

### [pluck](https://idlephp.tech/#pluck)

[](#pluck)

```
pluck($key, $collection)
```

Returns a new array by plucking the same named property off all records in the array supplied.

### [project](https://idlephp.tech/#project)

[](#project)

```
project($props, $collection)
```

Like SQL `select` statement.

### [prop](https://idlephp.tech/#prop)

[](#prop)

```
prop($key, $record)
```

Return the specified property.

### [propEq](https://idlephp.tech/#propEq)

[](#propeq)

```
propEq($value, $key, $record)
```

Returns $record\[$key\] == $value

### [propOr](https://idlephp.tech/#propOr)

[](#propor)

```
propOr($default, $key, $record)
```

Return the $key property or `$default`.

### [propSatisfies](https://idlephp.tech/#propSatisfies)

[](#propsatisfies)

```
propSatisfies($predicate, $key, $record)
```

Returns `$predicate($record[$key])`

### [rearg](https://idlephp.tech/#rearg)

[](#rearg)

```
rearg($indexes, $fn)
```

Returns a curried function that invokes `$fn` with arguments rearranged according to `$indexes`.

### [rebuild](https://idlephp.tech/#rebuild)

[](#rebuild)

```
rebuild($convert, $collection)
```

Transforms an object into a new one, applying to every key-value pair a function creating zero, one, or many new key-value pairs, and combining the results into a single object.

### [reduce](https://idlephp.tech/#reduce)

[](#reduce)

```
reduce($iteratee, $accumulator, $collection)
```

Reduces `$collection` to a value which is the accumulated result of running each element in collection through `$iteratee`.

### [remove](https://idlephp.tech/#remove)

[](#remove)

```
remove($start, $count, $iterable)
```

Removes items from `$iterable` starting at $start and containing `$count` elements.

### [renameKeys](https://idlephp.tech/#renameKeys)

[](#renamekeys)

```
renameKeys($mapping, $collection)
```

Converts an object to a new one by changing all keys that are also found as keys in a mapping object to their corresponding values from that object.

### [replace](https://idlephp.tech/#replace)

[](#replace)

```
replace($pattern, $replacement, $string)
```

Replace a regex match in a string with a replacement.

### [resolve](https://idlephp.tech/#resolve)

[](#resolve)

```
resolve($resolvers, $record)
```

Adds new properties to `$record` using `$resolvers`.

### [round](https://idlephp.tech/#round)

[](#round)

```
round($precision, $number)
```

Rounds $number to specified $precision

### [setPath](https://idlephp.tech/#setPath)

[](#setpath)

```
setPath($path, $value, $record)
```

Return copy of `$record` with `$path` set with `$value`.

### [slice](https://idlephp.tech/#slice)

[](#slice)

```
slice($start, $end, $collection)
```

Returns a slice of iterable or string from `$start` up to, but not including `$end`.

### [snakeCase](https://idlephp.tech/#snakeCase)

[](#snakecase)

```
snakeCase($string)
```

Converts `string` to snake case.

### [sort](https://idlephp.tech/#sort)

[](#sort)

```
sort($comparator, $collection)
```

Sorts `$collection` using `$comparator` comparison (`$a  $b`) function.

### [sortBy](https://idlephp.tech/#sortBy)

[](#sortby)

```
sortBy($iteratees, $collection)
```

Sorts `$collection` in ascending order according to `$comparators`.

### [sortWith](https://idlephp.tech/#sortWith)

[](#sortwith)

```
sortWith($comparators, $collection)
```

Sorts a `$collection` according to an array of comparison (`$a  $b`) functions.

### [split](https://idlephp.tech/#split)

[](#split)

```
split($separator, $string)
```

Splits string by `$separator` regular expression.

### [splitAt](https://idlephp.tech/#splitAt)

[](#splitat)

```
splitAt($index, $arrayOrString)
```

Splits a given array or string at a given index.

### [splitEvery](https://idlephp.tech/#splitEvery)

[](#splitevery)

```
splitEvery($length, $arrayOrString)
```

Splits an array or string into slices of the specified length.

### [splitWhen](https://idlephp.tech/#splitWhen)

[](#splitwhen)

```
splitWhen($predicate, $iterable)
```

Splits an array by predicate.

### [splitWhenever](https://idlephp.tech/#splitWhenever)

[](#splitwhenever)

```
splitWhenever($predicate, $iterable)
```

Splits an array into slices on every occurrence of a value.

### [startsWith](https://idlephp.tech/#startsWith)

[](#startswith)

```
startsWith($target, $string)
```

If string starts with `$target`.

### [subtract](https://idlephp.tech/#subtract)

[](#subtract)

```
subtract($a, $b)
```

$a - $b

### [sum](https://idlephp.tech/#sum)

[](#sum)

```
sum($collection)
```

Sums elements in $collection

### [sumBy](https://idlephp.tech/#sumBy)

[](#sumby)

```
sumBy($iteratee, $collection)
```

Sums elements, $iteratee is invoked for each element in $collection to generate the value to be summed.

### [T](https://idlephp.tech/#T)

[](#t)

```
T(...$args)
```

Always returns `true`

### [tail](https://idlephp.tech/#tail)

[](#tail)

```
tail($collection)
```

Returns all but the first element of the iterable or string.

### [take](https://idlephp.tech/#take)

[](#take)

```
take($n, $collection)
```

Takes `$n` first elements from iterable.

### [takeLast](https://idlephp.tech/#takeLast)

[](#takelast)

```
takeLast($n, $collection)
```

Returns a slice of iterable with `$n` elements taken from the end.

### [tap](https://idlephp.tech/#tap)

[](#tap)

```
tap($interceptor, $value)
```

Calls `$interceptor($value)` then returns the original `$value`.

### [times](https://idlephp.tech/#times)

[](#times)

```
times($iteratee, $n)
```

Calls the iteratee `$n` times, returning an array of the results of each invocation.

### [toLower](https://idlephp.tech/#toLower)

[](#tolower)

```
toLower($string)
```

Converts string to lower case.

### [toPairs](https://idlephp.tech/#toPairs)

[](#topairs)

```
toPairs($record)
```

Converts a record into an array of `[$key, $value]`.

### [toUpper](https://idlephp.tech/#toUpper)

[](#toupper)

```
toUpper($string)
```

Converts string to upper case.

### [trim](https://idlephp.tech/#trim)

[](#trim)

```
trim($characters, $string)
```

Strip characters from the beginning and end of a string.

### [trimEnd](https://idlephp.tech/#trimEnd)

[](#trimend)

```
trimEnd($characters, $string)
```

Strip characters from the end of a string.

### [trimStart](https://idlephp.tech/#trimStart)

[](#trimstart)

```
trimStart($characters, $string)
```

Strip characters from the beginning of a string.

### [tryCatch](https://idlephp.tech/#tryCatch)

[](#trycatch)

```
tryCatch($tryer, $catcher, $value)
```

Calls `$tryer`, if it throws, calls `$catcher`.

### [unapply](https://idlephp.tech/#unapply)

[](#unapply)

```
unapply($fn)
```

Returns fn (...$args) =&gt; $fn($args)

### [unary](https://idlephp.tech/#unary)

[](#unary)

```
unary($fn)
```

`ary(1, $fn)`

### [uniq](https://idlephp.tech/#uniq)

[](#uniq)

```
uniq($collection)
```

Removes duplicates using `===`.

### [uniqBy](https://idlephp.tech/#uniqBy)

[](#uniqby)

```
uniqBy($iteratee, $collection)
```

Like `uniq` but apply `$iteratee` fist.

### [uniqWith](https://idlephp.tech/#uniqWith)

[](#uniqwith)

```
uniqWith($predicate, $collection)
```

Like `uniq` but uses `$predicate` to compare elements.

### [unless](https://idlephp.tech/#unless)

[](#unless)

```
unless($predicate, $whenFalse, $value)
```

Returns `$predicate($value) ? $value : $whenFalse($value)`.

### [update](https://idlephp.tech/#update)

[](#update)

```
update($index, $value, $collection)
```

Returns a new copy of the array with the element at the provided index replaced with the given value.

### [upperFirst](https://idlephp.tech/#upperFirst)

[](#upperfirst)

```
upperFirst($string)
```

Converts the first character of string to upper case.

### [useWith](https://idlephp.tech/#useWith)

[](#usewith)

```
useWith($fn, $transformers)
```

Applies each transformer function to each argument. Returns a new curried functions.

### [values](https://idlephp.tech/#values)

[](#values)

```
values($collection)
```

Returns an indexed iterable of values in `$collection`.

### [when](https://idlephp.tech/#when)

[](#when)

```
when($predicate, $whenTrue, $value)
```

Returns `$predicate($value) ? $whenTrue($value) : $value`.

### [where](https://idlephp.tech/#where)

[](#where)

```
where($spec, $record)
```

Checks if `$record` satisfies the spec by invoking the `$spec` properties with the corresponding properties of $record.

### [whereAny](https://idlephp.tech/#whereAny)

[](#whereany)

```
whereAny($spec, $record)
```

Checks if `$record` satisfies the spec by invoking the $spec properties with the corresponding properties of `$record`. Returns true if at least one of the predicates returns true.

### [whereEq](https://idlephp.tech/#whereEq)

[](#whereeq)

```
whereEq($spec, $test)
```

Check if the `$test` satisfies the `$spec`.

### [without](https://idlephp.tech/#without)

[](#without)

```
without($values, $collection)
```

Returns `$iterable` without `$values`.

### [words](https://idlephp.tech/#words)

[](#words)

```
words($pattern, $string)
```

Splits string into an array of words.

### [zip](https://idlephp.tech/#zip)

[](#zip)

```
zip($a, $b)
```

Creates a new iterable out of the two supplied by pairing up equally-positioned items from both iterables.

### [zipAll](https://idlephp.tech/#zipAll)

[](#zipall)

```
zipAll($iterables)
```

Same as `zip` but for many iterables.

### [zipWith](https://idlephp.tech/#zipWith)

[](#zipwith)

```
zipWith($iteratee, $a, $b)
```

Like `zip` except that it accepts `$iteratee` to specify how grouped values should be combined.

###  Health Score

54

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 94% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~46 days

Recently: every ~2 days

Total

34

Last Release

71d ago

Major Versions

1.13.2 → 2.0.02026-01-20

PHP version history (2 changes)1.1.0PHP &gt;=7.4

2.0.0PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/71f1c0ca0e9a54fe4a3db3b4fac6a8b97e244bd68c75dd5dd8879867f470d79c?d=identicon)[miroshnikov](/maintainers/miroshnikov)

---

Top Contributors

[![miroshnikov](https://avatars.githubusercontent.com/u/574279?v=4)](https://github.com/miroshnikov "miroshnikov (79 commits)")[![justbyitself](https://avatars.githubusercontent.com/u/160424955?v=4)](https://github.com/justbyitself "justbyitself (4 commits)")[![ryansobol](https://avatars.githubusercontent.com/u/5688?v=4)](https://github.com/ryansobol "ryansobol (1 commits)")

---

Tags

functionallodashphpphp-libraryramdatoolboxtoolkittoolsutilitiesutilityutility-libraryutilsutilitylazyfunctionallodashramda

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/miroshnikov-idles/health.svg)

```
[![Health](https://phpackages.com/badges/miroshnikov-idles/health.svg)](https://phpackages.com/packages/miroshnikov-idles)
```

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k430.4M1.7k](/packages/nette-utils)[lodash-php/lodash-php

A port of Lodash to PHP

528756.5k5](/packages/lodash-php-lodash-php)[maciejczyzewski/bottomline

A full-on PHP manipulation utility belt that provides support for working with arrays, objects, and iterables; a lodash or underscore equivalent for PHP.

475643.1k10](/packages/maciejczyzewski-bottomline)[mpetrovich/dash

A functional programming library for PHP. Inspired by Underscore, Lodash, and Ramda.

10330.0k1](/packages/mpetrovich-dash)[phpcsstandards/phpcsutils

A suite of utility functions for use with PHP\_CodeSniffer

6340.1M95](/packages/phpcsstandards-phpcsutils)[me-io/php-lodash

A full-on PHP manipulation utility-belt that provides support for the usual functional.

39104.0k](/packages/me-io-php-lodash)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
