Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| SignerDisplayStatus | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| fromSignRequestStatus | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| getLabel | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** |
| 6 | * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors |
| 7 | * SPDX-License-Identifier: AGPL-3.0-or-later |
| 8 | */ |
| 9 | |
| 10 | namespace OCA\Libresign\Enum; |
| 11 | |
| 12 | use OCP\IL10N; |
| 13 | |
| 14 | /** |
| 15 | * What the current viewer is allowed to know about a signer. It is an API |
| 16 | * presentation value only: SignRequestStatus stays the workflow state and |
| 17 | * nothing here is persisted or used for authorization. |
| 18 | */ |
| 19 | enum SignerDisplayStatus: string { |
| 20 | case DRAFT = 'draft'; |
| 21 | case READY_TO_SIGN = 'ready_to_sign'; |
| 22 | case SIGNED = 'signed'; |
| 23 | case REJECTED = 'rejected'; |
| 24 | case OBSERVING = 'observing'; |
| 25 | /** The signer has not signed and the viewer may not know anything more specific. */ |
| 26 | case NOT_SIGNED = 'not_signed'; |
| 27 | |
| 28 | public static function fromSignRequestStatus(SignRequestStatus $status): self { |
| 29 | return match ($status) { |
| 30 | SignRequestStatus::DRAFT => self::DRAFT, |
| 31 | SignRequestStatus::ABLE_TO_SIGN => self::READY_TO_SIGN, |
| 32 | SignRequestStatus::SIGNED => self::SIGNED, |
| 33 | SignRequestStatus::REJECTED => self::REJECTED, |
| 34 | SignRequestStatus::OBSERVING => self::OBSERVING, |
| 35 | }; |
| 36 | } |
| 37 | |
| 38 | public function getLabel(IL10N $l10n): string { |
| 39 | return match ($this) { |
| 40 | self::DRAFT => SignRequestStatus::DRAFT->getLabel($l10n), |
| 41 | self::READY_TO_SIGN => SignRequestStatus::ABLE_TO_SIGN->getLabel($l10n), |
| 42 | self::SIGNED => SignRequestStatus::SIGNED->getLabel($l10n), |
| 43 | self::REJECTED => SignRequestStatus::REJECTED->getLabel($l10n), |
| 44 | self::OBSERVING => SignRequestStatus::OBSERVING->getLabel($l10n), |
| 45 | // TRANSLATORS Neutral signer status shown when the viewer may know only that this signer has not signed, without the reason or whether they still can. |
| 46 | self::NOT_SIGNED => $l10n->t('Not signed'), |
| 47 | }; |
| 48 | } |
| 49 | } |