/** * Returns the total elapsed time. * * This includes the times between previous start() and stop() calls if any, * as well as the time since the stopwatch was last started if it is running. * * @return Duration */ public function getElapsedTime() { if ($this->startTime === null) { return $this->duration; } return $this->duration->plus(Duration::between($this->startTime, Instant::now())); }