PHPackages                             kikytokamuro/futils - 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. kikytokamuro/futils

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

kikytokamuro/futils
===================

Functional utils

0.3.0(4y ago)03MITPHPPHP &gt;=7.4

Since Nov 24Pushed 4y ago1 watchersCompare

[ Source](https://github.com/KikyTokamuro/Futils)[ Packagist](https://packagist.org/packages/kikytokamuro/futils)[ RSS](/packages/kikytokamuro-futils/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Futils
======

[](#futils)

Functional utils

### Examples:

[](#examples)

#### All

[](#all)

Determines whether all elements of the array satisfies the predicate.

```
Futils\all(fn($x) => $x > 100)([101, 102, 103]) // => true
```

#### Always

[](#always)

Creates a function that always returns a given value.

```
Futils\always(true)() // => true
```

#### Any

[](#any)

Determines whether any element of the array satisfies the predicate.

```
Futils\any(fn($x) => $x == 100)([1, 2, 100]) // => true
```

#### Compose

[](#compose)

Function composition (fn -&gt; ... -&gt; f2 -&gt; f1).

```
Futils\compose(fn($x) => $x + 1, fn($x) => $x * 100)(2) // => 201
```

#### Contains

[](#contains)

Check whether a value is contained in a array.

```
Futils\contains(1337)([1, 1337, 2]) // => true
```

#### Difference

[](#difference)

Computes the difference of arrays.

```
Futils\difference([1, 2, 3, 4])([1, 2]) // => [3, 4]
```

#### Drop

[](#drop)

Drops the first n elements off the front of the array.

```
Futils\drop(2)([1, 2, 3, 4]) // => [3, 4]
```

#### Filter

[](#filter)

Filters elements of an array using a callback function.

```
Futils\filter(fn($x) => $x > 0)([-1, -2, 1, 2]) // => [1, 2]
```

#### Find

[](#find)

Find first element of the array satisfies the predicate.

```
Futils\find(fn($x) => $x > 10)([1, 2, 11]) // => 11
```

#### Flatten

[](#flatten)

Flattens nested arrays.

```
Futils\flatten([1, [2, [3, [4]]]]) // => [1, 2, 3, 4]
```

#### Has

[](#has)

Check if exists element with this key in array.

```
Futils\has("test")(["test" => 1]) // => true
```

#### Head

[](#head)

Get head of array.

```
Futils\head([1, 2, 3]) // => 1
```

#### IndexOf

[](#indexof)

Get first index of value in array.

```
Futils\indexOf("test")([1, "test", 3]) // => 1
```

#### Join

[](#join)

Join array elements with a string.

```
Futils\join([1, 2, 3])("|") // => "1|2|3"
```

#### Last

[](#last)

Get last element of array.

```
Futils\last([1, 2, 3, 4]) // => 4
```

#### Map

[](#map)

Applying function to each element of array.

```
Futils\map(fn($x) => $x + 1)([1, 2, 3]) // => [2, 3, 4]
```

#### Merge

[](#merge)

Merge two arrays.

```
Futils\merge([1, 2])([3, 4]) // => [1, 2, 3, 4]
```

#### Partial

[](#partial)

Create partial function.

```
Futils\partial(fn($x, $y, $z) => $x + $y + $z)(1, 2)(3) // => 6
```

#### Partition

[](#partition)

Equivalent to \[(filter f, arr), (reject f, arr)\]

```
Futils\partition(fn($x) => $x > 0)([-1, -2, 1, 2]) // => [[1, 2], [-1, -2]]
```

#### Pipe

[](#pipe)

Function composition (f1 -&gt; f2 -&gt; ... -&gt; fn).

```
Futils\pipe(fn($x) => $x + 1, fn($x) => $x * 100)(1) // => 200
```

#### Reduce

[](#reduce)

Reduce the array to a single value using a callback function.

```
Futils\reduce(fn($x, $y) => $x + $y)([1, 2, 3]) // => 6
```

#### Reject

[](#reject)

Like filter, but the new array is composed of all the items which fail the function.

```
Futils\reject(fn($x) => $x > 0)([-1, -2, 1, 2]) // => [-1, -2]
```

#### Replace

[](#replace)

Replaces elements from passed arrays into the first array.

```
Futils\replace([1, 2, 3])([1 => 3, 2 => 2]) // => [1, 3, 2]
```

#### Tail

[](#tail)

Get tail of array

```
Futils\tail([1, 2, 3, 4, 5]) // => [2, 3, 4, 5]
```

#### Take

[](#take)

Get n first elements from array.

```
Futils\take(2)([1, 2, 3, 4]) // => [1, 2]
```

#### When

[](#when)

Only when predicate is true then appling function to argument, else return argument.

```
Futils\when(fn($x) => $x > 100)(fn($x) => $x + 5)(1000) // => 1005
```

#### Zip

[](#zip)

Zips together its two arguments into a array of arrays.

```
Futils\zip([1, 2, 3])([4, 5, 6]) // => [[1, 4], [2, 5], [3, 6]]
```

#### Monads

[](#monads)

**IdentityMonad** - Just annotates plain values and functions to satisfy the monad laws.

```
(new Futils\IdentityMonad(100))
    ->bind(fn($x, $n) => $x * $n, 2)
    ->bind("strval")
    ->extract() // => "200"
```

**MaybeMonad** - Encapsulates the type of an undefined value.

```
(new Futils\MaybeMonad("test"))
    ->bind(fn() => null)
    ->bind(fn($x) => $x + 1)
    ->extract() // => null
```

**ListMonad** - Abstracts away the concept of a list of items.

```
(new Futils\ListMonad([1, new IdentityMonad(2), new MaybeMonad(3), new ListMonad([4])]))
    ->bind(fn($x) => $x + 100)
    ->extract() // => [101, 102, 103, [104]]
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~2 days

Total

3

Last Release

1625d ago

PHP version history (2 changes)0.1.0PHP ^7.4

0.2.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a1c89dca801085298b9ce6b97bfb7b4f39a797c53a674aac31924c890643991?d=identicon)[KikyTokamuro](/maintainers/KikyTokamuro)

---

Top Contributors

[![KikyTokamuro](https://avatars.githubusercontent.com/u/9868440?v=4)](https://github.com/KikyTokamuro "KikyTokamuro (9 commits)")

---

Tags

fpfunctional-programmingphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kikytokamuro-futils/health.svg)

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

###  Alternatives

[stevegrunwell/wp-admin-tabbed-settings-pages

A polyfill for Trac #51086, bringing tabbed settings pages into WP-Admin.

1446.2k](/packages/stevegrunwell-wp-admin-tabbed-settings-pages)

PHPackages © 2026

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