PostgresArtefaktKatalog.php
Pfad: src/Infrastructure/Persistence/PostgresArtefaktKatalog.php
Ext: php
Größe: 1035 Bytes
Geändert: 2026-07-16T00:34:32+02:00
Frühere Version vom 2026-07-16T00:34:32+02:00 · zur aktuellen Fassung
<?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()->query('SELECT typ, bezeichner FROM artefakt ORDER BY typ, bezeichner');
$out = [];
foreach ($stmt === false ? [] : $stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
$out[] = new KatalogEintrag((string) $row['typ'], (string) $row['bezeichner']);
}
return $out;
}
}