PHPackages                             tijmenwierenga/repositories - 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. tijmenwierenga/repositories

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

tijmenwierenga/repositories
===========================

A set of utilities to create repositories with superpowers.

v0.3.0(4y ago)22.2k[1 issues](https://github.com/TijmenWierenga/repository-utilities/issues)MITPHPPHP ^7.4|^8.0CI failing

Since Aug 31Pushed 4y ago1 watchersCompare

[ Source](https://github.com/TijmenWierenga/repository-utilities)[ Packagist](https://packagist.org/packages/tijmenwierenga/repositories)[ RSS](/packages/tijmenwierenga-repositories/feed)WikiDiscussions master Synced yesterday

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

Repository utilities for PHP applications
=========================================

[](#repository-utilities-for-php-applications)

The in-memory repository
------------------------

[](#the-in-memory-repository)

The `TijmenWierenga\Repositories\InMemoryRepository` is a simple array-based storage that performs persistence related actions.

#### `all(): T[]`

[](#all-t)

Returns all items stored in the repository.

```
$users = [
    new User(1),
    new User(2),
    new User(3),
];

$repository = new InMemoryRepository($users);

$users = $repository->all(); // returns an array with all users.
```

#### `find(Closure $criteria): T|null`

[](#findclosure-criteria-tnull)

Returns the first item that matches the criteria. Returns `null` is no match is found

```
$users = [
    new User(1),
    new User(2),
    new User(3),
];

$repository = new InMemoryRepository($users);

$user = $repository->find(fn (User $user): bool => $user->id === 1); // Returns user with ID of 1.
```

#### `findMany(Closure $criteria): T[]`

[](#findmanyclosure-criteria-t)

Returns all items that match the criteria.

```
$users = [
    new User(1),
    new User(2),
    new User(3),
];

$repository = new InMemoryRepository($users);

$user = $repository->findMany(fn (User $user): bool => $user->id > 1); // Returns all users with a ID greater than 1.
```

#### `add(T $item): void`

[](#addt-item-void)

Adds a new item to the collection.

```
$repository = new InMemoryRepository();

$repository->add(new User(1)); // User is now added to the collection.
```

#### `remove(Closure $criteria): void`

[](#removeclosure-criteria-void)

Removes all items from the collection that match the criteria.

```
$users = [
    new User(1),
    new User(2),
    new User(3),
];

$repository = new InMemoryRepository($users);

$repository->remove(fn (User $user): bool => $user->id === 1); // Removes user with an ID of 1.
```

#### `first(): T|null`

[](#first-tnull)

Returns the first item in the collection. Returns `null` is the collection is empty.

```
$users = [
    new User(1),
    new User(2),
    new User(3),
];

$repository = new InMemoryRepository($users);

$repository->first(); // Returns User(1)
```

#### `last(): T|null`

[](#last-tnull)

Returns the last item in the collection. Returns `null` is the collection is empty.

```
$users = [
    new User(1),
    new User(2),
    new User(3),
];

$repository = new InMemoryRepository($users);

$repository->last(); // Returns User(3)
```

#### `map(Closure $function): U`

[](#mapclosure-function-u)

Returns a new repository instance based on the returned values of the closure.

```
$users = [
    new User(1),
    new User(2),
    new User(3),
];

$repository = new InMemoryRepository($users);

$usernames = $repository->map(fn (User $user): string => $user->username()); // Returns InMemoryRepository with usernames
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Total

4

Last Release

1799d ago

PHP version history (2 changes)v0.1.0PHP ^7.4

v0.3.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/52381e72d9e3b301a071a0a30cd72592e595fa17838beabb00ac2e7ebbd98275?d=identicon)[TijmenWierenga](/maintainers/TijmenWierenga)

---

Top Contributors

[![TijmenWierenga](https://avatars.githubusercontent.com/u/8513032?v=4)](https://github.com/TijmenWierenga "TijmenWierenga (14 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tijmenwierenga-repositories/health.svg)

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

PHPackages © 2026

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