validate(); try { $serviceContext = $this->getServiceContext(); $this->saveToolStates(); $isTerminated = (bool) $this->getRunnerService()->isTerminated($serviceContext); if (!$isTerminated) { $this->saveItemState(); } if ($this->shouldTimerStopOnPause($isTerminated)) { $this->endItemTimer($this->getTime()); } if ($this->getRequestParameter('offline') === true) { $this->setOffline(); } $result = $this->getRunnerService()->pause($serviceContext); $response = [ 'success' => $result ]; } catch (Exception $e) { $response = $this->getErrorResponse($e); } return $response; } /** * @param bool $isTerminated * @return bool */ private function shouldTimerStopOnPause(bool $isTerminated): bool { if (!$isTerminated) { $timerTarget = $this->getRunnerService()->getTestConfig()->getConfigValue('timer.target'); if ($timerTarget === 'client') { return true; } } return false; } }