Lines
50.00%
3 / 6
Methods
50.00%
3 / 6
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| __destruct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| subscribe | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| unsubscribe | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| isRequested | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| throwIfRequested | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| 11 | final class ManualTimeout implements Cancellation | |
| 12 | { | |
| 13 | public function __construct( | |
| 14 | private readonly Cancellation $cancellation, | |
| 15 | private readonly TimerHandle $timer, | |
| 16 | ) {} | |
| 17 | ||
| 18 | // Mirrors TimeoutCancellation: an abandoned deadline must not stay pending. | |
| 19 | public function __destruct() | |
| 20 | { | |
| 21 | $this->timer->cancel(); | |
| 22 | } | |
| 23 | ||
| 24 | public function subscribe(Closure $callback): string | |
| 25 | { | |
| 26 | return $this->cancellation->subscribe($callback); | |
| 27 | } | |
| 28 | ||
| 29 | public function unsubscribe(string $id): void | |
| 30 | { | |
| 31 | $this->cancellation->unsubscribe($id); | |
| 32 | } | |
| 33 | ||
| 34 | public function isRequested(): bool | |
| 35 | { | |
| 36 | return $this->cancellation->isRequested(); | |
| 37 | } | |
| 38 | ||
| 39 | public function throwIfRequested(): void | |
| 40 | { | |
| 41 | $this->cancellation->throwIfRequested(); | |
| 42 | } | |
| 43 | } |