> $records */ public function __construct( private array $records = [], ) {} /** @return list> */ public function findAll(array $query = []): array { return array_values($this->records); } /** @return array|null */ public function find(int|string $id): ?array { return $this->records[$id] ?? null; } /** @return array */ public function create(array $values): array { $id = count($this->records) + 1; $record = ['id' => $id] + $values; $this->records[$id] = $record; return $record; } /** @return array|null */ public function update(int|string $id, array $values): ?array { if (!isset($this->records[$id])) { return null; } $this->records[$id] = ['id' => $id] + $values; return $this->records[$id]; } public function delete(int|string $id): bool { if (!isset($this->records[$id])) { return false; } unset($this->records[$id]); return true; } public function count(array $query = []): int { return count($this->records); } }