Backup #1909

ID1909
Dateipfad/var/www/dev.campus.systemische-tools.de/src/Domain/ValueObject/MessageTiming.php
Version2
Typ modified
Größe1.9 KB
Hash805f3cdb13ba8f5627102a4a8e4f632c2f8bd74154b23ea4e0052ffe07add0c1
Datum2025-12-28 01:07:15
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

declare(strict_types=1);

namespace Domain\ValueObject;

// @responsibility: Immutable Value Object for message timing (performance tracking)

use Domain\Constants;
use InvalidArgumentException;

final class MessageTiming
{
    private ?float $startMicrotime;
    private ?float $endMicrotime;

    private function __construct(?float $startMicrotime, ?float $endMicrotime)
    {
        if ($startMicrotime !== null && $endMicrotime !== null && $endMicrotime < $startMicrotime) {
            throw new InvalidArgumentException('End time cannot be before start time');
        }

        $this->startMicrotime = $startMicrotime;
        $this->endMicrotime = $endMicrotime;
    }

    public static function create(?float $startMicrotime, ?float $endMicrotime): self
    {
        return new self($startMicrotime, $endMicrotime);
    }

    public static function none(): self
    {
        return new self(null, null);
    }

    public static function started(float $startMicrotime): self
    {
        return new self($startMicrotime, null);
    }

    public function startMicrotime(): ?float
    {
        return $this->startMicrotime;
    }

    public function endMicrotime(): ?float
    {
        return $this->endMicrotime;
    }

    public function durationMs(): ?float
    {
        if ($this->startMicrotime === null || $this->endMicrotime === null) {
            return null;
        }

        return ($this->endMicrotime - $this->startMicrotime) * 1000;
    }

    public function isComplete(): bool
    {
        return $this->startMicrotime !== null && $this->endMicrotime !== null;
    }

    public function withEnd(float $endMicrotime): self
    {
        return new self($this->startMicrotime, $endMicrotime);
    }

    public function equals(self $other): bool
    {
        return $this->startMicrotime === $other->startMicrotime
            && $this->endMicrotime === $other->endMicrotime;
    }
}

Vollständig herunterladen

Aktionen

Herunterladen

Andere Versionen dieser Datei

ID Version Typ Größe Datum
1909 2 modified 1.9 KB 2025-12-28 01:07
1906 1 modified 1.9 KB 2025-12-28 01:06

← Zurück zur Übersicht