ContentSourceRepository.php

Code Hygiene Score: 100

Keine Issues gefunden.

Dependencies 3

Klassen 1

Funktionen 2

Verwendet von 1

Code

<?php

declare(strict_types=1);

namespace Infrastructure\Persistence;

// @responsibility: Persistenz für Content-Sources

use Domain\Repository\ContentSourceRepositoryInterface;

class ContentSourceRepository implements ContentSourceRepositoryInterface
{
    private \PDO $pdo;

    public function __construct(\PDO $pdo)
    {
        $this->pdo = $pdo;
    }

    public function findSourcesByOrder(int $orderId): array
    {
        $stmt = $this->pdo->prepare('
            SELECT cs.*, c.content, d.filename as document_name
            FROM content_sources cs
            JOIN chunks c ON cs.chunk_id = c.id
            JOIN documents d ON c.document_id = d.id
            WHERE cs.order_id = :order_id
            ORDER BY cs.relevance_score DESC
        ');
        $stmt->execute(['order_id' => $orderId]);

        return $stmt->fetchAll();
    }
}
← Übersicht Graph