Backup #1222
| ID | 1222 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Domain/DTO/PipelineDocumentDTO.php |
| Version | 1 |
| Typ |
modified |
| Größe | 2.2 KB |
| Hash | 53d27869d9674d2cb54b430a4c49bdef6e469fd5b7fa77b2068b72e04af95d01 |
| Datum | 2025-12-25 10:49:55 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Write-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?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
{
return new self(
id: (int) $row['id'],
pipelineId: (int) $row['pipeline_id'],
filename: (string) $row['filename'],
filepath: (string) $row['filepath'],
mimeType: (string) ($row['mime_type'] ?? 'application/octet-stream'),
fileSize: (int) ($row['file_size'] ?? 0),
status: DocumentStatus::from((string) ($row['status'] ?? 'pending')),
errorMessage: $row['error_message'] ?? null,
chunkCount: (int) ($row['chunk_count'] ?? 0),
createdAt: new \DateTimeImmutable($row['created_at'] ?? 'now'),
processedAt: isset($row['processed_at']) ? new \DateTimeImmutable($row['processed_at']) : 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 = $this->fileSize;
$unitIndex = 0;
while ($size >= 1024 && $unitIndex < count($units) - 1) {
$size /= 1024;
$unitIndex++;
}
return round($size, 2) . ' ' . $units[$unitIndex];
}
}
Vollständig herunterladen
Aktionen
← Zurück zur Übersicht