MessageTiming.php
- Pfad:
src/Domain/ValueObject/MessageTiming.php - Namespace: Domain\ValueObject
- Zeilen: 77 | Größe: 1,951 Bytes
- Geändert: 2025-12-28 01:07:15 | 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 2
- use Domain\Constants
- use InvalidArgumentException
Klassen 1
-
MessageTimingclass Zeile 12
Funktionen 10
-
__construct()private Zeile 17 -
create()public Zeile 27 -
none()public Zeile 32 -
started()public Zeile 37 -
startMicrotime()public Zeile 42 -
endMicrotime()public Zeile 47 -
durationMs()public Zeile 52 -
isComplete()public Zeile 61 -
withEnd()public Zeile 66 -
equals()public Zeile 71
Verwendet von 3
- ChatMessage.php constructor
- ChatMessage.php use
- ChatMessageFactory.php use
Versionen 2
-
v2
2025-12-28 01:07 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v1
2025-12-28 01:06 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?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) * Constants::MS_PER_SECOND;
}
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;
}
}