955eb5bb3bfb2af0b9f1870e6fdabf8914ac9d72
[yaffs-website] / vendor / consolidation / robo / src / Common / Timer.php
1 <?php
2 namespace Robo\Common;
3
4 trait Timer
5 {
6     /**
7      * @var \Robo\Common\TimeKeeper
8      */
9     protected $timer;
10
11     protected function startTimer()
12     {
13         if (!isset($this->timer)) {
14             $this->timer = new TimeKeeper();
15         }
16         $this->timer->start();
17     }
18
19     protected function stopTimer()
20     {
21         if (!isset($this->timer)) {
22             return;
23         }
24         $this->timer->stop();
25     }
26
27     /**
28      * @return float|null
29      */
30     protected function getExecutionTime()
31     {
32         if (!isset($this->timer)) {
33             return null;
34         }
35         return $this->timer->elapsed();
36     }
37 }