Conditions | 4 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
25 | 6 | public function add($time, Deferred $deferred) |
|
26 | 6 | { |
|
27 | 6 | $time = filter_var($time, FILTER_VALIDATE_FLOAT); |
|
28 | 6 | if ($time === false) { |
|
29 | 1 | throw new \InvalidArgumentException('Delay must be number.'); |
|
30 | } |
||
31 | 5 | if ($time < 0) { |
|
32 | 1 | throw new \DomainException('Delay must be positive.'); |
|
33 | } |
||
34 | do { |
||
35 | 4 | $id = uniqid(); |
|
36 | 4 | } while (isset($this->untils[$id])); |
|
37 | 4 | $this->untils[$id] = microtime(true) + $time; |
|
38 | 4 | $this->deferreds[$id] = $deferred; |
|
39 | 4 | } |
|
40 | |||
88 |