| Total Complexity | 8 |
| Total Lines | 69 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class BenchmarkService |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var mixed |
||
| 19 | */ |
||
| 20 | protected $startTime; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var |
||
| 24 | */ |
||
| 25 | protected $endTime; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | protected $name; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * TimeService constructor. |
||
| 34 | * @param string $name |
||
| 35 | */ |
||
| 36 | public function __construct(string $name) |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Get result |
||
| 43 | * @return mixed |
||
| 44 | */ |
||
| 45 | public function result() |
||
| 46 | { |
||
| 47 | if (!$this->endTime) { |
||
| 48 | $this->stop(); |
||
| 49 | } |
||
| 50 | |||
| 51 | if (!$this->startTime) { |
||
| 52 | $this->setDefaultStartTime(); |
||
| 53 | } |
||
| 54 | |||
| 55 | return $this->endTime - $this->startTime; |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Start measure |
||
| 60 | */ |
||
| 61 | public function start() |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * End measure |
||
| 68 | */ |
||
| 69 | public function stop() |
||
| 70 | { |
||
| 71 | $this->endTime = microtime(true); |
||
| 72 | } |
||
| 73 | |||
| 74 | |||
| 75 | /** |
||
| 76 | * Get StartTime if such exists |
||
| 77 | */ |
||
| 78 | protected function setDefaultStartTime() |
||
| 84 | } |
||
| 85 | } |
||
| 86 | |||
| 87 | } |