Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
timer.php
1<?php
2
4
6
11{
13 private $timeLimit = 15;
14
16 private $startTime = -1;
17
21 public function __construct($timeLimit = -1)
22 {
23 if ($timeLimit > 0)
24 {
25 $this->setTimeLimit($timeLimit);
26 }
27 }
28
36 public function startTimer($startingTime = null)
37 {
38 if ((int)$startingTime > 0)
39 {
40 $this->startTime = (int)$startingTime;
41 }
42 else
43 {
44 $this->startTime = \time();
45 }
46
47 return $this;
48 }
49
55 public function hasTimeLimitReached()
56 {
57 if ($this->timeLimit > 0 && $this->startTime > 0)
58 {
59 if ((\time() - $this->startTime) >= $this->timeLimit)
60 {
61 return true;
62 }
63 }
64
65 return false;
66 }
67
72 public function getTimeLimit()
73 {
74 return $this->timeLimit;
75 }
76
84 public function setTimeLimit($timeLimit)
85 {
86 $this->timeLimit = $timeLimit;
87
88 return $this;
89 }
90}
91
startTimer($startingTime=null)
Definition timer.php:36