KoniKode · Software built with intention

KNOWLEDGE BASE

Documentation

DOCUMENTATION
CURRENT APPLICATIONClean Framework
DocumentationClean Framework

Clean Framework · DOCUMENTATION

Source: InMemoryReadingListRepository.php

Source: InMemoryReadingListRepository.php

Bounded candidate reference — 2026-10-20: 0.2.0-rc.1 is committed locally through 84f415b3098af5653577b2c65eea31fca21df79c, unpublished and not production-approved; stable PHP >=8.5.11 <8.6.0 is required. This is documentation, not adoption: this knowledge base retains its installed 0.1.0-rc.1 dependency and PHP 8.2.11 local profile. Dated PHP 8.2 evidence is historical; earlier dirty-source reports retain their original test provenance, not retroactive clean-commit proof. Candidate examples are illustrative: API signatures were reviewed, but candidate code was not executed by this editorial update. See current checkpoint, open criteria and adoption boundary.

Origin: examples/reading-list/app/Repositories/InMemoryReadingListRepository.php

<?php

declare(strict_types=1);

namespace Portability\ReadingList\Repositories;

use InvalidArgumentException;
use Portability\ReadingList\Domain\ReadingItem;

/** Deterministic no-database repository used only by the portability example. */
final class InMemoryReadingListRepository implements ReadingListRepository
{
    /** @var array<string,ReadingItem> */
    private array $items = [];

    /** @param list<ReadingItem> $items Bind an explicit duplicate-free fixture. */
    public function __construct(array $items)
    {
        foreach ($items as $item) {
            if (!$item instanceof ReadingItem || isset($this->items[$item->slug()])) {
                throw new InvalidArgumentException('Reading-list fixture is invalid or duplicated.');
            }
            $this->items[$item->slug()] = $item;
        }
    }

    /** Return entries in their application-defined insertion order. */
    public function all(): array
    {
        return array_values($this->items);
    }

    /** Return one exact entry without fuzzy or user-controlled query behavior. */
    public function findBySlug(string $slug): ?ReadingItem
    {
        return $this->items[$slug] ?? null;
    }
}

Editorial provenance

Source: examples/reading-list/app/Repositories/InMemoryReadingListRepository.php. Source SHA-256: d788c1e5c5142184daaee234fbe744901781919e5e2315986d767b98b79b224d.

Framework candidate reference; editorial checkpoint 2026-10-20. See candidate status and adoption boundary.

EXPLORE FURTHER

Drag a divider or use Left and Right Arrow keys to resize. Hold Shift for larger steps. Enter hides or restores the sidebar; Home and End select its minimum or maximum width. Double-click resets the width.

Install KoniKode