1 | <?php |
||
5 | class TimeKeeper |
||
6 | { |
||
7 | const MINUTE = 60; |
||
8 | const HOUR = 3600; |
||
9 | const DAY = 86400; |
||
10 | |||
11 | /** |
||
12 | * @var float|null |
||
13 | */ |
||
14 | protected $startedAt; |
||
15 | |||
16 | /** |
||
17 | * @var float|null |
||
18 | */ |
||
19 | protected $finishedAt; |
||
20 | |||
21 | public function start() |
||
29 | |||
30 | public function stop() |
||
34 | |||
35 | public function reset() |
||
39 | |||
40 | /** |
||
41 | * @return float|null |
||
42 | */ |
||
43 | public function elapsed() |
||
51 | |||
52 | /** |
||
53 | * Format a duration into a human-readable time. |
||
54 | * |
||
55 | * @param float $duration |
||
56 | * Duration in seconds, with fractional component. |
||
57 | * |
||
58 | * @return string |
||
59 | */ |
||
60 | public static function formatDuration($duration) |
||
76 | } |
||
77 |