for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Fyuze\Debug;
class Timer
{
/**
* @var
*/
protected $timers;
protected $current;
* @param string $name
* @return float
public function start($name = 'default')
$this->current = $name;
$start = microtime(true);
$this->timers[$name]['start'] = $start;
return $start;
return $start
string
double
}
* @param null $name
$name
null
* @return array
public function stop($name = null)
$key = ($name !== null || ($name && array_key_exists($name, $this->timers))) ? $name : 'default';
false
void
integer|string
$key
array_key_exists()
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
$key = ($name !== null || ($name && array_key_exists(/** @scrutinizer ignore-type */ $name, $this->timers))) ? $name : 'default';
$this->timers[$key]['stop'] = microtime(true);
/** @var $start float */
/** @var $stop float */
extract($this->timers[$key]);
$this->timers[$key]['duration'] = $stop - $start;
return $this->timers[$key];
*
public function getTimers()
return $this->timers;
* @param \Closure $closure
public function transaction(\Closure $closure)
$this->start();
$closure();
return $this->stop();