| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3.009 |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | 5 | public function waitForThrottle() { |
|
| 24 | 5 | if (!$this->lastTime) { |
|
| 25 | 2 | $this->lastTime = \microtime(true); |
|
| 26 | 2 | return; |
|
| 27 | } |
||
| 28 | |||
| 29 | 4 | $now = \microtime(true); |
|
| 30 | 4 | $diff = $this->interval - ($now - $this->lastTime); |
|
| 31 | |||
| 32 | 4 | if ($diff > 0) { |
|
| 33 | usleep((int)ceil($diff * 1000 * 1000)); |
||
| 34 | } |
||
| 35 | |||
| 36 | 4 | $this->lastTime = \microtime(true); |
|
| 37 | 4 | } |
|
| 38 | |||
| 49 |