Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/translate/lib/controller/ |
Upload File : |
<?php namespace Bitrix\Translate\Controller; use Bitrix\Translate; /** * Timer class. */ class Timer implements Translate\Controller\ITimeLimit { /** @var int seconds */ private $timeLimit = 15; /** @var float seconds */ private $startTime = -1; /** * @param int $timeLimit Timeout in seconds. */ public function __construct($timeLimit = -1) { if ($timeLimit > 0) { $this->setTimeLimit($timeLimit); } } /** * Start up timer. * * @param int $startingTime Starting time. * * @return self */ public function startTimer($startingTime = null) { if ((int)$startingTime > 0) { $this->startTime = (int)$startingTime; } else { $this->startTime = \time(); } return $this; } /** * Tells true if time limit reached. * * @return boolean */ public function hasTimeLimitReached() { if ($this->timeLimit > 0 && $this->startTime > 0) { if ((\time() - $this->startTime) >= $this->timeLimit) { return true; } } return false; } /** * Gets limitation time in seconds. * @return int */ public function getTimeLimit() { return $this->timeLimit; } /** * Sets limitation time in seconds. * * @param int $timeLimit Timeout in seconds. * * @return self */ public function setTimeLimit($timeLimit) { $this->timeLimit = $timeLimit; return $this; } }