PHPackages                             digitalrevolution/utils - 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. digitalrevolution/utils

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

digitalrevolution/utils
=======================

A library for everyday use utility classes

v1.29.0(2mo ago)161.7k↑15.5%7[1 issues](https://github.com/123inkt/utils/issues)2MITPHPPHP &gt;=8.1CI passing

Since Jul 20Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/123inkt/utils)[ Packagist](https://packagist.org/packages/digitalrevolution/utils)[ RSS](/packages/digitalrevolution-utils/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (22)Versions (38)Used By (2)

[![Minimum PHP Version](https://camo.githubusercontent.com/230588f62e4b3ba29858fcfcf1bbfe253f82c4180088091d6c7d4c6c06d80145/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e312d383839324246)](https://php.net/)

DR Utility Classes
------------------

[](#dr-utility-classes)

A library with everyday use classes and methods:

Arrays
------

[](#arrays)

- `first` - Get the first element of an array, exception otherwise.
- `firstOrNull` - Get the first element of an array, null otherwise.
- `last` - Get the last element of an array, exception otherwise.
- `lastOrNull` - Get the last element of an array, null otherwise.
- `find` - Find the first element in an array that matches a predicate, exception otherwise.
- `findOrNull` - Find the first element in an array that matches a predicate, null otherwise.
- `flatten` - Recursively flattens an array returning an array with all the elements.
- `contains` - Test if the given value is contained within items. Supports `EquatableInterface`.
- `diff` - Get the difference between two arrays. Supports `ComparableInterface`.
- `equals` - Tests if two arrays have equal contents, ignoring order. Supports `ComparableInterface`.
- `explode` - Explode a string or null into an array, with exploding empty string to empty array.
- `map` - Similar to `array_map` but with support for `iterable`, and receive key as second argument in the callback.
- `mapAssoc` - Map an array to a new array using a callback, preserving keys.
- `mapKeys` - Map an array to a new keyed array using a callback,
- `reindex` - Reindex an array with new keys based on the result of the callback.
- `groupBy` - Group items by the given return value of the callback.
- `renameKey` - Rename the `string` key of an array element.
- `remove` - Remove an element from an array based on the callback. Supports `EquatableInterface`.
- `removeKey` - Remove an element from an array based on the key.
- `removeKeys` - Remove multiple elements from an array based on the keys.
- `removeTypes` - Filters an array by removing all values that match the provided types.
- `removeNull` - Filters an array by removing all null values.
- `search` - Find the key of an element in an array or false otherwise. Supports `EquatableInterface`.
- `unique` - Remove duplicate values from an array. Supports `EquatableInterface`.
- `wrap` - Wrap a value in an array, unless it is already an array.
- `toJson` - Converts an array into a json string.
- `fromJson` - Converts a json string into an array.
- `fetchByPath` - Fetch a value from a multi-dimensional array by the given path.
- `assignByPath` - Assign a value to a multi-dimensional array by the given path.

Assert
------

[](#assert)

Fluent assertion methods, inspired by `webmozart/assert`:

- `null`
- `notNull`
- `isArray`
- `inArray`
- `isCallable`
- `resource`
- `object`
- `scalar`
- `integer`
- `positiveInt`
- `negativeInt`
- `nonNegativeInt`
- `nonPositiveInt`
- `numeric`
- `float`
- `string`
- `classString`
- `startsWith`
- `notStartsWith`
- `endsWith`
- `notEndsWith`
- `boolean`
- `true`
- `false`
- `notFalse`
- `emptyArray`
- `nonEmptyArray`
- `nonEmptyString`
- `isInstanceOf`
- `greaterThan` - Supports `ComparableInterface`.
- `lessThan` - Supports `ComparableInterface`.
- `type`
- `fileExists`
- `file`
- `directory`
- `readable`
- `writable`

### Example

[](#example)

```
$value = Assert::notNull($this->repository->find(123));
```

Stringify
---------

[](#stringify)

### `::value(mixed $value): string`

[](#valuemixed-value-string)

Easily convert any value to a string representation.

```
true > 'true'
false > 'false'
null > 'null'
123 > '123'
1.23 > '1.23'
'abc' > 'abc'
'' > 'empty-string',
[] > 'empty-array'
[1, 2, 3] > 'array-list(3)'
['foo' => 'bar'] => 'keyed-array(1)'
StringableObject => 'value (StringableObject)'
stdClass => 'stdClass'
resource => 'resource (stream)'
```

Closures
--------

[](#closures)

- `unfold`

Turns a variable with a closure into the return type of that closure.
Can be called multiple times on the same variable, but will only execute the closure once.

```
    $service = fn() => new Service();
    Closures::unfold($service);
    $service instanceof Service // true
```

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

[](#installation)

```
composer require digitalrevolution/utils
```

About us
--------

[](#about-us)

At 123inkt (Part of Digital Revolution B.V.), every day more than 50 development professionals are working on improving our internal ERP and our several shops. Do you want to join us? [We are looking for developers](https://www.werkenbij123inkt.nl/zoek-op-afdeling/it).

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance66

Regular maintenance activity

Popularity34

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 65.2% 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 ~28 days

Recently: every ~47 days

Total

35

Last Release

74d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fe1034dcdc9935e9b7f7a733490a5095282445a8526e30e9097e0782c78e24c1?d=identicon)[bram123](/maintainers/bram123)

![](https://www.gravatar.com/avatar/d144b8d21d1631a75230f12330a9cb0ef6608581a5e6989c18677ac52295e271?d=identicon)[FrankDekker](/maintainers/FrankDekker)

![](https://www.gravatar.com/avatar/20e2ae81f6cffdb8c1b1a488b7f2f70270a5d1bf2a57aae09950697ac0ef3dad?d=identicon)[123Tim](/maintainers/123Tim)

---

Top Contributors

[![frankdekker](https://avatars.githubusercontent.com/u/2179983?v=4)](https://github.com/frankdekker "frankdekker (43 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (7 commits)")[![avgeeklucky](https://avatars.githubusercontent.com/u/30637897?v=4)](https://github.com/avgeeklucky "avgeeklucky (5 commits)")[![cardoso123inkt](https://avatars.githubusercontent.com/u/139959874?v=4)](https://github.com/cardoso123inkt "cardoso123inkt (5 commits)")[![bram123](https://avatars.githubusercontent.com/u/7457368?v=4)](https://github.com/bram123 "bram123 (2 commits)")[![danny-janse](https://avatars.githubusercontent.com/u/3527340?v=4)](https://github.com/danny-janse "danny-janse (1 commits)")[![pvalk123inkt](https://avatars.githubusercontent.com/u/197891201?v=4)](https://github.com/pvalk123inkt "pvalk123inkt (1 commits)")[![RubenKluft](https://avatars.githubusercontent.com/u/212696652?v=4)](https://github.com/RubenKluft "RubenKluft (1 commits)")[![WouterVeen](https://avatars.githubusercontent.com/u/3602494?v=4)](https://github.com/WouterVeen "WouterVeen (1 commits)")

---

Tags

arrayarraysassertassertionsphputility

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/digitalrevolution-utils/health.svg)

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

###  Alternatives

[daijie/aria2

talk with aria2

736.8k](/packages/daijie-aria2)

PHPackages © 2026

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