ContentCollectionService.php
- Pfad:
src/Application/ContentCollectionService.php - Namespace: Application
- Zeilen: 99 | Größe: 2,696 Bytes
- Geändert: 2025-12-23 08:09:35 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 100
- Dependencies: 100 (25%)
- LOC: 100 (20%)
- Methods: 100 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 100 (10%)
Keine Issues gefunden.
Dependencies 4
- constructor Infrastructure\Persistence\CollectionRepository
- constructor Infrastructure\Validation\CollectionValidator
- use Infrastructure\Persistence\CollectionRepository
- use Infrastructure\Validation\CollectionValidator
Klassen 1
-
ContentCollectionServiceclass Zeile 12
Funktionen 5
-
__construct()public Zeile 14 -
getAvailable()public Zeile 25 -
validate()public Zeile 44 -
checkCompatibility()public Zeile 58 -
validateWithCompatibility()public Zeile 78
Verwendet von 3
- ContentController.php constructor
- ContentController.php use
- ContentServiceProvider.php use
Versionen 1
-
v1
2025-12-23 08:09 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?php
declare(strict_types=1);
namespace Application;
// @responsibility: Service für RAG-Collection-Operationen und Validierung
use Infrastructure\Persistence\CollectionRepository;
use Infrastructure\Validation\CollectionValidator;
final class ContentCollectionService
{
public function __construct(
private CollectionRepository $repository,
private CollectionValidator $validator
) {
}
/**
* Get available collections for content generation.
*
* @return array<int, array<string, mixed>>
*/
public function getAvailable(): array
{
$collections = $this->repository->getSearchable();
if ($collections === []) {
return [
['collection_id' => 'documents', 'display_name' => 'Dokumente', 'points_count' => 0, 'vector_size' => 1024],
];
}
return $collections;
}
/**
* Validate and filter collections against available ones.
*
* @param array<string> $collections
* @return array<string>
*/
public function validate(array $collections): array
{
$availableIds = array_column($this->getAvailable(), 'collection_id');
$valid = array_filter($collections, fn ($c) => in_array($c, $availableIds, true));
return array_values($valid);
}
/**
* Check if collections are compatible (same vector dimensions).
*
* @param array<string> $collectionIds
* @return array{valid: bool, error: string|null}
*/
public function checkCompatibility(array $collectionIds): array
{
if (empty($collectionIds)) {
return ['valid' => true, 'error' => null];
}
$result = $this->validator->validateSelection($collectionIds);
return [
'valid' => $result->isValid(),
'error' => $result->getError(),
];
}
/**
* Validate collections and check compatibility in one call.
*
* @param array<string> $collections
* @return array{collections: array<string>, valid: bool, error: string|null}
*/
public function validateWithCompatibility(array $collections): array
{
$validated = $this->validate($collections);
if (empty($validated)) {
return [
'collections' => [],
'valid' => false,
'error' => 'Keine gültigen Collections ausgewählt',
];
}
$compatibility = $this->checkCompatibility($validated);
return [
'collections' => $validated,
'valid' => $compatibility['valid'],
'error' => $compatibility['error'],
];
}
}