Lines
100.00%
9 / 9
Methods
100.00%
4 / 4
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| attachWatcher | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| markFired | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| cancel | 100.00% | 5 / 5 | 100.00% | 1 / 1 | 2 | ||
| isPending | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| 11 | final class RevoltTimerHandle implements TimerHandle | |
| 12 | { | |
| 13 | private ?string $identifier = null; | |
| 14 | ||
| 15 | private bool $pending = true; | |
| 16 | ||
| 17 | public function attachWatcher(string $identifier): void | |
| 18 | { | |
| 19 | $this->identifier = $identifier; | |
| 20 | } | |
| 21 | ||
| 22 | public function markFired(): void | |
| 23 | { | |
| 24 | $this->pending = false; | |
| 25 | $this->identifier = null; | |
| 26 | } | |
| 27 | ||
| 28 | public function cancel(): void | |
| 29 | { | |
| 30 | $this->pending = false; | |
| 31 | ||
| 32 | if ($this->identifier === null) { | |
| 33 | return; | |
| 34 | } | |
| 35 | ||
| 36 | EventLoop::cancel($this->identifier); | |
| 37 | $this->identifier = null; | |
| 38 | } | |
| 39 | ||
| 40 | public function isPending(): bool | |
| 41 | { | |
| 42 | return $this->pending; | |
| 43 | } | |
| 44 | } |