diff --git a/src/Stopwatch.php b/src/Stopwatch.php index c2a9e7b..8d4c21f 100644 --- a/src/Stopwatch.php +++ b/src/Stopwatch.php @@ -7,7 +7,6 @@ use Exception; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Htmlable; -use Override; use Stringable; /** @@ -91,13 +90,15 @@ public function totalRunDuration(): CarbonInterval throw new Exception('Stopwatch has not been finished yet.'); } - return $this->endTime->diffAsCarbonInterval($this->startTime); + return $this->endTime->diffAsCarbonInterval($this->startTime, absolute: true); }); } private function totalRunDurationReadable(): string { - return "{$this->totalRunDuration()->totalMilliseconds}ms"; + $ms = round($this->totalRunDuration()->totalMilliseconds, 1); + + return "{$ms}ms"; } public function dd(mixed ...$args): never @@ -116,7 +117,6 @@ public function dump(mixed ...$args): self return $this; } - #[Override] public function toHtml(): string { $this->finish(); @@ -183,7 +183,6 @@ public function toString(): string return $this->totalRunDurationReadable(); } - #[Override] public function __toString(): string { return $this->toString(); @@ -198,7 +197,6 @@ public function __toString(): string * totalRunDurationMs: int, * } */ - #[Override] public function toArray(): array { $this->finish(); diff --git a/src/StopwatchCheckpoint.php b/src/StopwatchCheckpoint.php index 80bc2bb..b1732b6 100644 --- a/src/StopwatchCheckpoint.php +++ b/src/StopwatchCheckpoint.php @@ -5,7 +5,6 @@ use Carbon\CarbonImmutable; use Carbon\CarbonInterval; use Illuminate\Contracts\Support\Arrayable; -use Override; use Stringable; /** @@ -34,10 +33,10 @@ public function __construct( ) { $this->time = CarbonImmutable::now(); - $this->timeSinceStopwatchStart = $this->time->diffAsCarbonInterval($stopwatchStartTime)->cascade(); + $this->timeSinceStopwatchStart = $this->time->diffAsCarbonInterval($stopwatchStartTime, absolute: true)->cascade(); $this->timeSinceLastCheckpoint = $previousCheckpoint !== null - ? $this->time->diffAsCarbonInterval($previousCheckpoint->time)->cascade() + ? $this->time->diffAsCarbonInterval($previousCheckpoint->time, absolute: true)->cascade() : $this->timeSinceStopwatchStart; $this->timeSinceLastCheckpointFormatted = round($this->timeSinceLastCheckpoint->totalMilliseconds, 1) . 'ms'; @@ -117,7 +116,6 @@ private function renderMetadata(): string * timeSinceLastCheckpointFormatted: string, * } */ - #[Override] public function toArray(): array { return [