Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
12 / 12 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| ProgressPollDecisionPolicy | |
100.00% |
12 / 12 |
|
100.00% |
4 / 4 |
12 | |
100.00% |
1 / 1 |
| normalizeCachedStatus | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
3 | |||
| initialStatusFromCache | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| statusFromCacheChange | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| statusFromProgressChange | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | /** |
| 5 | * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors |
| 6 | * SPDX-License-Identifier: AGPL-3.0-or-later |
| 7 | */ |
| 8 | |
| 9 | namespace OCA\Libresign\Service\SignRequest; |
| 10 | |
| 11 | class ProgressPollDecisionPolicy { |
| 12 | public function normalizeCachedStatus(mixed $cachedStatus): ?int { |
| 13 | return ($cachedStatus !== false && $cachedStatus !== null) ? (int)$cachedStatus : null; |
| 14 | } |
| 15 | |
| 16 | public function initialStatusFromCache(?int $cachedStatus, int $initialStatus): ?int { |
| 17 | if ($cachedStatus === null) { |
| 18 | return null; |
| 19 | } |
| 20 | |
| 21 | return $cachedStatus !== $initialStatus ? $cachedStatus : null; |
| 22 | } |
| 23 | |
| 24 | public function statusFromCacheChange(?int $previousStatus, ?int $currentStatus): ?int { |
| 25 | if ($currentStatus === null || $currentStatus === $previousStatus) { |
| 26 | return null; |
| 27 | } |
| 28 | return $currentStatus; |
| 29 | } |
| 30 | |
| 31 | public function statusFromProgressChange(?int $currentStatus, ?int $previousStatus, int $initialStatus): int { |
| 32 | if ($currentStatus !== null) { |
| 33 | return $currentStatus; |
| 34 | } |
| 35 | if ($previousStatus !== null) { |
| 36 | return $previousStatus; |
| 37 | } |
| 38 | return $initialStatus; |
| 39 | } |
| 40 | } |