← Code-Übersicht

PostgresArtefaktKatalog.php

Pfad: src/Infrastructure/Persistence/PostgresArtefaktKatalog.php

Ext: php

Größe: 1063 Bytes

Geändert: 2026-07-16 10:48:18+02

<?php
declare(strict_types=1);

namespace Demo\Infrastructure\Persistence;

use Demo\Domain\Abgleich\ArtefaktKatalog;
use Demo\Domain\Abgleich\KatalogEintrag;
use PDO;

/**
 * Postgres-Adapter: liest alle Artefakte als Katalog-Eintraege.
 */
final class PostgresArtefaktKatalog implements ArtefaktKatalog
{
    /** @var PdoConnectionFactory Verbindungs-Fabrik. */
    private PdoConnectionFactory $factory;

    /**
     * @param PdoConnectionFactory $factory Injizierte Verbindungs-Fabrik.
     */
    public function __construct(PdoConnectionFactory $factory)
    {
        $this->factory = $factory;
    }

    /**
     * @inheritDoc
     */
    public function alle(): array
    {
        $stmt = $this->factory->create()->prepare('SELECT typ, bezeichner FROM artefakt ORDER BY typ, bezeichner');
        $stmt->execute();
        $out = [];
        foreach ($stmt === false ? [] : $stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
            $out[] = new KatalogEintrag((string) $row['typ'], (string) $row['bezeichner']);
        }

        return $out;
    }
}

Frühere Versionen

Version Zeitpunkt Operation
3 2026-07-16 12:49:36.48574+02 UPDATE