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; } }