1234567891011121314151617181920212223 |
- <?php
- namespace demo\Services;
- class Timer {
- const SCALE = 1E4;
- protected $t0;
- protected function __construct($t0) {
- $this->t0 = $t0;
- }
- public static function create() {
- return new static(microtime(true));
- }
- public function delay() {
- $diff = microtime(true) - $this->t0;
- return round($diff * static::SCALE);
- }
- }
|