PipelineDocumentDTO.php
- Pfad:
src/Domain/DTO/PipelineDocumentDTO.php - Namespace: Domain\DTO
- Zeilen: 95 | Größe: 2,981 Bytes
- Geändert: 2025-12-25 11:17:31 | 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 3
- constructor Domain\ValueObject\DocumentStatus
- constructor DateTimeImmutable
- use Domain\ValueObject\DocumentStatus
Klassen 1
-
PipelineDocumentDTOclass Zeile 11
Funktionen 5
-
__construct()public Zeile 13 -
fromDatabaseRow()public Zeile 33 -
canReprocess()public Zeile 65 -
isProcessing()public Zeile 73 -
fileSizeFormatted()public Zeile 81
Versionen 1
-
v1
2025-12-25 10:49 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Write-Operation
Code
<?php
declare(strict_types=1);
namespace Domain\DTO;
use Domain\ValueObject\DocumentStatus;
// @responsibility: DTO für Pipeline-Dokument-Daten
final readonly class PipelineDocumentDTO
{
public function __construct(
public int $id,
public int $pipelineId,
public string $filename,
public string $filepath,
public string $mimeType,
public int $fileSize,
public DocumentStatus $status,
public ?string $errorMessage,
public int $chunkCount,
public \DateTimeImmutable $createdAt,
public ?\DateTimeImmutable $processedAt,
) {
}
/**
* Create from database row.
*
* @param array<string, mixed> $row
*/
public static function fromDatabaseRow(array $row): self
{
$id = isset($row['id']) ? (int) $row['id'] : 0;
$pipelineId = isset($row['pipeline_id']) ? (int) $row['pipeline_id'] : 0;
$filename = isset($row['filename']) ? (string) $row['filename'] : '';
$filepath = isset($row['filepath']) ? (string) $row['filepath'] : '';
$mimeType = isset($row['mime_type']) ? (string) $row['mime_type'] : 'application/octet-stream';
$fileSize = isset($row['file_size']) ? (int) $row['file_size'] : 0;
$statusStr = isset($row['status']) ? (string) $row['status'] : 'pending';
$errorMessage = isset($row['error_message']) ? (string) $row['error_message'] : null;
$chunkCount = isset($row['chunk_count']) ? (int) $row['chunk_count'] : 0;
$createdAtStr = isset($row['created_at']) ? (string) $row['created_at'] : 'now';
$processedAtStr = isset($row['processed_at']) ? (string) $row['processed_at'] : null;
return new self(
id: $id,
pipelineId: $pipelineId,
filename: $filename,
filepath: $filepath,
mimeType: $mimeType,
fileSize: $fileSize,
status: DocumentStatus::from($statusStr),
errorMessage: $errorMessage,
chunkCount: $chunkCount,
createdAt: new \DateTimeImmutable($createdAtStr),
processedAt: $processedAtStr !== null ? new \DateTimeImmutable($processedAtStr) : null,
);
}
/**
* Check if document can be reprocessed.
*/
public function canReprocess(): bool
{
return $this->status->canReprocess();
}
/**
* Check if document is currently processing.
*/
public function isProcessing(): bool
{
return $this->status->isActive();
}
/**
* Get file size in human-readable format.
*/
public function fileSizeFormatted(): string
{
$units = ['B', 'KB', 'MB', 'GB'];
$size = (float) $this->fileSize;
$unitIndex = 0;
while ($size >= 1024 && $unitIndex < count($units) - 1) {
$size /= 1024;
$unitIndex++;
}
return round($size, 2) . ' ' . $units[$unitIndex];
}
}