| Total Complexity | 7 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 4 | class Timer |
||
| 5 | { |
||
| 6 | /** |
||
| 7 | * @var |
||
| 8 | */ |
||
| 9 | protected $timers; |
||
| 10 | |||
| 11 | protected $current; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @param string $name |
||
| 15 | * @return float |
||
| 16 | */ |
||
| 17 | 2 | public function start($name = 'default') |
|
| 18 | { |
||
| 19 | 2 | $this->current = $name; |
|
| 20 | |||
| 21 | 2 | $start = microtime(true); |
|
| 22 | |||
| 23 | 2 | $this->timers[$name]['start'] = $start; |
|
| 24 | |||
| 25 | 2 | return $start; |
|
|
|
|||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param null $name |
||
| 30 | * @return array |
||
| 31 | */ |
||
| 32 | 2 | public function stop($name = null) |
|
| 33 | { |
||
| 34 | 2 | $key = ($name !== null || ($name && array_key_exists($name, $this->timers))) ? $name : 'default'; |
|
| 35 | |||
| 36 | 2 | $this->timers[$key]['stop'] = microtime(true); |
|
| 37 | |||
| 38 | /** @var $start float */ |
||
| 39 | /** @var $stop float */ |
||
| 40 | 2 | extract($this->timers[$key]); |
|
| 41 | |||
| 42 | 2 | $this->timers[$key]['duration'] = $stop - $start; |
|
| 43 | |||
| 44 | 2 | return $this->timers[$key]; |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * |
||
| 49 | */ |
||
| 50 | 1 | public function getTimers() |
|
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @param \Closure $closure |
||
| 57 | * @return array |
||
| 58 | */ |
||
| 59 | 1 | public function transaction(\Closure $closure) |
|
| 68 |