Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
63.64% covered (warning)
63.64%
7 / 11
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
FileStatus
63.64% covered (warning)
63.64%
7 / 11
50.00% covered (danger)
50.00%
1 / 2
3.43
0.00% covered (danger)
0.00%
0 / 1
 allowsSignerRemoval
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 getLabel
60.00% covered (warning)
60.00%
6 / 10
0.00% covered (danger)
0.00%
0 / 1
1.06
1<?php
2
3declare(strict_types=1);
4
5/**
6 * SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
7 * SPDX-License-Identifier: AGPL-3.0-or-later
8 */
9
10namespace OCA\Libresign\Enum;
11
12use OCP\IL10N;
13
14/**
15 * File status enum
16 *
17 * Represents all possible states a LibreSign file can be in
18 */
19enum FileStatus: int {
20    case NOT_LIBRESIGN_FILE = -1;
21    case DRAFT = 0;
22    case ABLE_TO_SIGN = 1;
23    case PARTIAL_SIGNED = 2;
24    case SIGNED = 3;
25    case DELETED = 4;
26    case SIGNING_IN_PROGRESS = 5;
27    case CANCELED = 6;
28
29    public function allowsSignerRemoval(): bool {
30        return $this === self::DRAFT || $this === self::ABLE_TO_SIGN;
31    }
32
33    public function getLabel(IL10N $l10n): string {
34        return match($this) {
35            // TRANSLATORS File status shown when the file is not part of any LibreSign signing flow.
36            self::NOT_LIBRESIGN_FILE => $l10n->t('Not LibreSign file'),
37            // TRANSLATORS File status shown while the signature request is still being prepared.
38            self::DRAFT => $l10n->t('Draft'),
39            // TRANSLATORS File status shown when at least one signer can sign now.
40            self::ABLE_TO_SIGN => $l10n->t('Ready to sign'),
41            // TRANSLATORS File status shown when some required signers have signed, but not all.
42            self::PARTIAL_SIGNED => $l10n->t('Partially signed'),
43            // TRANSLATORS File status shown when the signing workflow is complete: at least one signature was applied and no signer is still pending. Signers who rejected count as done.
44            self::SIGNED => $l10n->t('Signed'),
45            // TRANSLATORS File status shown when the LibreSign file record was deleted.
46            self::DELETED => $l10n->t('Deleted'),
47            // TRANSLATORS File status shown during asynchronous background signing operations.
48            self::SIGNING_IN_PROGRESS => $l10n->t('Signing in progress'),
49            // TRANSLATORS File status shown when the signing workflow was closed because a signer rejected the signature request.
50            self::CANCELED => $l10n->t('Canceled'),
51        };
52    }
53}