PHPackages                             dryist/functions - 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. dryist/functions

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

dryist/functions
================

Functions for common tasks

0.4.0(7y ago)541MITPHPPHP ^7.2

Since Dec 24Pushed 7y ago2 watchersCompare

[ Source](https://github.com/dryist/functions)[ Packagist](https://packagist.org/packages/dryist/functions)[ RSS](/packages/dryist-functions/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (6)Used By (0)

Dryist Functions
================

[](#dryist-functions)

[![Build Status](https://camo.githubusercontent.com/54a3797ec45a2a2dd749f73e78c6f07e3f3d19c1dcc0dfc64a9fb1b1a7628633/68747470733a2f2f7472617669732d63692e636f6d2f6472796973742f66756e6374696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/dryist/functions)[![Code Quality](https://camo.githubusercontent.com/012a9d1785553d37296c04480c0c26fdeeef69d06194af7a280d34cb5d6743b3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6472796973742f66756e6374696f6e732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dryist/functions/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/d3b04acba8d8a6494b63d9a6ae0aea3fb77a00fc92abb9b198b4b8e6d16074b2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6472796973742f66756e6374696f6e732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dryist/functions/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/f32965de5985d98c33e6eaf0c8bc2ad685364c932d39d1d368ac5a15d1733be3/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6472796973742f66756e6374696f6e732e7376673f7374796c653d666c6174)](https://packagist.org/packages/dryist/functions)[![Total Downloads](https://camo.githubusercontent.com/348b4dfa40ef164d0adea725b4a815622dea7f2d06d482485cc5f5510497f871/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6472796973742f66756e6374696f6e732e7376673f7374796c653d666c6174)](https://packagist.org/packages/dryist/functions)[![License](https://camo.githubusercontent.com/d67c424b10ef143c78626dc4ac762206bd152f69e03a8c65d5188df38db90bf4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6472796973742f66756e6374696f6e732e7376673f7374796c653d666c6174)](https://packagist.org/packages/dryist/functions)

A variety of utility functions for common programming needs.

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

[](#installation)

The best way to install and use this package is with [composer](http://getcomposer.org/):

```
composer require dryist/functions
```

Usage
-----

[](#usage)

There are several categories of functions:

- [algebra](#algebra) - some common functional language utilities
- [array](#array) - helpers to work with arrays and iterators
- [tool](#tool) - other various tools

All functions have a constant that refers the fully qualified function name. These constants can be used for composed or piped operations.

There are a number of other packages that provide compatible (and/or similar) utility functions, including:

-
-
-

Any functionality missing in this package can probably be found elsewhere.

### Alegbra

[](#alegbra)

#### always()

[](#always)

Creates a "K combinator" that always returns the original value:

```
use function Dryist\always;

$fn = always(true);

assert($fn() === true);
```

#### compose()

[](#compose)

Creates a "substitution combinator" that composes two callables:

```
use function Dryist\compose;

$fn = compose('ucwords', 'strtolower');

assert($fn('SALLY SMITH') === 'Sally Smith');
```

#### identity()

[](#identity)

Always returns the first input:

```
use function Dryist\identity;

assert(identity('foo') === 'foo');
```

*This function is also aliased as `Dryist\id`.*

#### invert()

[](#invert)

Creates an inverted predicate:

```
use function Dryist\invert;

$notNull = invert('is_null');

assert($notNull(42) === true);
assert($notNull(null) === true);
```

### Array

[](#array)

All of the array functions accept [`iterable`](https://php.net/manual/language.types.iterable.php) variables, including arrays, iterators, and generators.

#### count()

[](#count)

Count the number of items in a list or map:

```
use function Dryist\count;

$items = [1, 2, 3];

assert(count($items) === 3);
```

#### combine()

[](#combine)

Combines two lists to create a map:

```
use function Dryist\combine;
use function Dryist\resolve;

$keys = ['city', 'country'];
$values = ['London', 'England'];
$map = combine($keys, $values);

assert(resolve($map) === ['city' => 'London', 'country' => 'England']);
```

#### filter()

[](#filter)

Filter a list or map by a predicate of the value:

```
use function Dryist\filter;
use function Dryist\resolve;
use function Dryist\values;

$positive = function (int $value): bool {
    return $value > 0;
};

$list = [-100, 0, 100];
$list = filter($list, $positive);

// Drop keys
$list = values($list);

assert(resolve($list) === [100]);
```

#### filterKey()

[](#filterkey)

Filter a list or map by a predicate of the key:

```
use function Dryist\filterKey;
use function Dryist\resolve;
use function Dryist\values;

$even = function (int $value): bool {
    return $value % 2 === 0;
};

$map = [13 => 'a', 16 => 'b', 22 => 'c'];
$map = filterKey($map, $even);

// Drop keys
$list = values($map);

assert(resolve($list) === ['b', 'c']);
```

Related functions:

- [take](#take)

#### keys()

[](#keys)

Read the keys from a map into a list:

```
use function Dryist\keys;
use function Dryist\resolve;

$map = ['name' => 'Jane', 'friends' => 42];
$keys = keys($map);

assert(resolve($keys) === ['name', 'friends']);
```

#### map()

[](#map)

Apply a value modifier to a list or map:

```
use function Dryist\map;
use function Dryist\resolve;

$list = ['foo', 'bar', 'baz'];
$list = map($list, 'strtoupper');

assert(resolve($list) === ['FOO', 'BAR', 'BAZ']);
```

#### mapBoth()

[](#mapboth)

Apply a value modifier to a list or map:

```
use function Dryist\mapBoth;
use function Dryist\resolve;

$list = ['foo', 'bar', 'baz'];
$list = mapBoth($list, function ($key, $value) {
    if ($key % 2 === 0) {
        return strtoupper($value);
    }
    return $value;
});

assert(resolve($list) === ['FOO', 'bar', 'BAZ']);
```

*This differs from map() in that the modifier receives both the key and the value.*

#### mapKey()

[](#mapkey)

Apply a key modifier to a list or map:

```
use function Dryist\mapKey;
use function Dryist\resolve;

$map = ['NAME' => 'Bob', 'GAME' => 'football'];
$map = mapKey($map, 'strtolower');

assert(resolve($map) === ['name' => 'Bob', 'game' => 'football'])
```

#### resolve()

[](#resolve)

An alias for [`iterator_to_array`](https://php.net/iterator_to_array).

#### take()

[](#take)

Take some values from a map by a list of keys:

```
use function Dryist\resolve;
use function Dryist\take;

$map = ['name' => 'Cassie', 'friends' => 152, 'age' => 39];
$map = take($map, ['name']);

assert(resolve($map) === ['name' => 'Cassie']);
```

#### values()

[](#values)

Read the values of a map into a list:

```
use function Dryist\values;
use function Dryist\resolve;

$map = ['a' => 1, 'b' => 2, 'c' => 3];
$list = values($map);

assert(resolve($list) === [1, 2, 3]);
```

### Tool

[](#tool)

#### make()

[](#make)

Create a modifier that constructs an object.

```
use function Dryist\make;
use function Dryist\map;
use function Dryist\resolve;

$list = [[1, 2, 3], [4, 5], [6]];
$list = map($list, make(ArrayIterator::class));

assert(resolve($list)[0] instanceof ArrayIterator);
```

#### stringify()

[](#stringify)

Convert a value to a string, unless it is null.

```
use function Dryist\stringify;

assert(stringify(null) === null);
assert(stringify(42) === "42");
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

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 ~1 days

Total

5

Last Release

2693d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/38203?v=4)[Woody Gilk](/maintainers/shadowhand)[@shadowhand](https://github.com/shadowhand)

---

Top Contributors

[![shadowhand](https://avatars.githubusercontent.com/u/38203?v=4)](https://github.com/shadowhand "shadowhand (20 commits)")

---

Tags

algebrafunctionalfunctionshelpersiteratorphputilityarraycommoniteratorfunctionalfunctions

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dryist-functions/health.svg)

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

###  Alternatives

[nikic/iter

Iteration primitives using generators

1.1k5.9M38](/packages/nikic-iter)[athari/yalinqo

YaLinqo, a LINQ-to-objects library for PHP

4561.2M5](/packages/athari-yalinqo)[ihor/nspl

Non-standard PHP library (NSPL) - functional primitives toolbox and more

381368.5k](/packages/ihor-nspl)[ginq/ginq

LINQ to Object inspired DSL for PHP

192257.5k3](/packages/ginq-ginq)[crell/fp

Functional utilities for PHP 8 and later

91429.8k11](/packages/crell-fp)[markrogoyski/itertools-php

Iteration tools for PHP

14911.3k](/packages/markrogoyski-itertools-php)

PHPackages © 2026

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