Generates InMemory repository implementations for PHP 8.4 testing. Creates fake repositories with array storage, supporting CRUD operations and queries without database.
From accnpx claudepluginhub dykyi-roman/awesome-claude-code --plugin accThis skill uses the workspace's default tool permissions.
references/examples.mdreferences/other-fakes.mdGenerates InMemory (Fake) repository implementations for testing.
<?php
declare(strict_types=1);
namespace Tests\Fake;
use {RepositoryInterface};
use {Entity};
use {EntityId};
final class InMemory{Entity}Repository implements {RepositoryInterface}
{
/** @var array<string, {Entity}> */
private array $entities = [];
public function save({Entity} $entity): void
{
$this->entities[$entity->id()->toString()] = $entity;
}
public function findById({EntityId} $id): ?{Entity}
{
return $this->entities[$id->toString()] ?? null;
}
public function delete({Entity} $entity): void
{
unset($this->entities[$entity->id()->toString()]);
}
/** @return list<{Entity}> */
public function findAll(): array
{
return array_values($this->entities);
}
public function clear(): void
{
$this->entities = [];
}
}
Read the repository interface:
Generate InMemory implementation:
clear() for test cleanupHandle complex queries:
array_filter for criteriaarray_sliceAdd test helpers (optional):
getAll() — access internal statehas(Id $id) — check existencecount() — entity countFile placement:
tests/Fake/InMemory{Entity}Repository.phptests/Double/ directoryclear() in tearDownreferences/examples.md — Complete repository examples (User, Order, Product)references/other-fakes.md — EventDispatcher, Mailer, Clock fakesProvides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.