digitalrevolution/utils
A PHP 8.3+ utility library of everyday helper classes, focused on array operations such as first/last, find, flatten, map, groupBy, diff, unique, remove, JSON conversion, and path fetching, plus iterable and string helpers.
Code Quality & Maintainability:
Developer Productivity:
Arrays::flatten, Arrays::toIntList, Assert::notNull) instead of reinventing them.Consistency & Best Practices:
Assert::isArray, Assert::greaterThan) across services, reducing edge-case bugs.Arrays::groupBy, Arrays::diff, Arrays::toIntList) to ensure predictable behavior — notably, a single sanctioned way to normalize ID lists (query params, form arrays, CSV splits) rather than scattered array_map('intval', ...) casts.Roadmap Alignment:
Closures::unfold to lazy-load heavy services (e.g., external APIs) behind feature flags.Arrays::mapAssoc/Arrays::reindex for API payload transformations, and Arrays::toIntList for normalizing identifier collections at the boundary of new integrations.if (empty($var)) checks with fluent assertions (e.g., Assert::nonEmptyArray($data)) in validation-heavy flows.Build vs. Buy:
array_key_exists() with Arrays::contains()).Assert::notNull() with custom failure messages).ComparableInterface/EquatableInterface support) for complex data structures (e.g., DTOs, collections)."This utility package is a force multiplier for our development team. By adopting digitalrevolution/utils, we can:
Arrays::equals() ensures predictable comparisons, Arrays::toIntList() removes hand-rolled ID casting).Assert::nonEmptyString() for input validation).For a one-time Composer install (composer require digitalrevolution/utils), we gain a reusable toolkit used internally by a 50+ developer team at 123inkt. This aligns with our goal to [reduce technical debt] while keeping costs minimal."
"This package solves three key pain points:
array_map, array_filter, and nested foreach loops with fluent methods like Arrays::flatten(), Arrays::groupBy(), and Arrays::fetchByPath().
$grouped = Arrays::groupBy($users, fn($user) => $user['department']);
$ids = Arrays::toIntList($request->input('ids', []));
if chains with expressive assertions:
Assert::nonEmptyArray($payload)->notNull($payload['id'])->positiveInt($payload['quantity']);
ComparableInterface.Closures::unfold() for lazy initialization (e.g., feature flags) and Stringify::value() for debugging.Migration Path:
Arrays::mapAssoc for payload transformations, Arrays::toIntList for ID normalization).unfold for deferred service initialization.Risks: Minimal—package is MIT-licensed, PHP 8.3+, and actively maintained. v1.34.0 is an additive, non-breaking release (Arrays::toIntList plus a dev-only PHPMD v3 bump that does not affect consumers). We can phase adoption by service."*
How can I help you explore Laravel packages today?