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

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

moj/utils
=========

Some utility functions

1.3.0(5y ago)0198[1 PRs](https://github.com/marcusorjames/utils/pulls)MITPHPPHP &gt;=7.0

Since Nov 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/marcusorjames/utils)[ Packagist](https://packagist.org/packages/moj/utils)[ RSS](/packages/moj-utils/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (2)Versions (7)Used By (0)

MOJ Utility Classes
===================

[](#moj-utility-classes)

Introduction
------------

[](#introduction)

Some lightweight utility classes to plug missing basic functions in php

Arrays
------

[](#arrays)

```
use MOJ\Utils\Arrays;
```

### Rename Array keys

[](#rename-array-keys)

```
$input = ['foo', 'bar'];
$renamedArray = Arrays::rename(['foo' => 'hello', 'bar' => 'world']);
// returns $renamedArray = ['hello', 'world']
```

### Flatten Array

[](#flatten-array)

```
$input = [[0],[1],[2]];
$flattenedArray = Arrays::flatten($input);
// returns $flattenedArray = [0, 1, 2];
```

### Flatten Array with glue

[](#flatten-array-with-glue)

```
$input = [
    'book'         => 'Dune',
    'housePlanets' => [
        'Atreides'  => 'Caladan',
        'Harkonnen' => 'Giedi Prime',
    ],
    'houses'       => [
        [
            'name'       => 'Atreides',
            'homePlanet' => 'Caladan',
            'leader'     => 'Duke Leto',
        ],
        [
            'name'       => 'Harkonnen',
            'homePlanet' => 'Geidi Prime',
            'leader'     => 'Baron',
        ]
    ],
    'rating'       => '*****',
];
$flattendArray = Arrays::flatten($input, '.');
// returns $flattenedArray = [
//            'book'                   => 'Dune',
//            'housePlanets.Atreides'  => 'Caladan',
//            'housePlanets.Harkonnen' => 'Giedi Prime',
//            'houses.0.name'          => 'Atreides',
//            'houses.0.homePlanet'    => 'Caladan',
//            'houses.0.leader'        => 'Duke Leto',
//            'houses.1.name'          => 'Harkonnen',
//            'houses.1.homePlanet'    => 'Geidi Prime',
//            'houses.1.leader'        => 'Baron',
//            'rating'                 => '*****',
//        ];
```

### Intersect Array by key recursively

[](#intersect-array-by-key-recursively)

```
$array1 = [
    'book'         => 'Dune',
    'housePlanets' => [
        'Atreides'  => 'Caladan',
        'Harkonnen' => 'Giedi Prime',
    ],
    'rating'       => '*****',
];

$array2 = [
    'book'         => null,
    'housePlanets' => [
        'Harkonnen' => null,
    ]
];

$intersectedArray = Arrays::intersectKeyRecursive($array1, $array2);

//        $intersectedArray = [
//            'book'         => 'Dune',
//            'housePlanets' => [
//                'Harkonnen' => 'Giedi Prime',
//            ],
//        ];
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

Total

3

Last Release

2187d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/853845?v=4)[marcusorjames](/maintainers/marcusorjames)[@marcusorjames](https://github.com/marcusorjames)

---

Top Contributors

[![marcusorjames](https://avatars.githubusercontent.com/u/853845?v=4)](https://github.com/marcusorjames "marcusorjames (11 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[hansschouten/phpagebuilder

A drag and drop pagebuilder to manage pages in any PHP project.

86857.2k3](/packages/hansschouten-phpagebuilder)[raulr/google-play-scraper

A PHP scraper to get app data from Google Play

12892.7k](/packages/raulr-google-play-scraper)[thunderer/platenum

PHP enum library

36145.7k](/packages/thunderer-platenum)[etechnika/idna-convert

Etechnika.eu idna-convert

16392.1k3](/packages/etechnika-idna-convert)[koalafacade/filament-alertbox

Alert box field for Filament forms

2337.0k](/packages/koalafacade-filament-alertbox)[wpbp/cronplus

Add/Remove a WordPress Cron job easily

2610.0k](/packages/wpbp-cronplus)

PHPackages © 2026

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