Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| SignatureFlow | |
100.00% |
11 / 11 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| toNumeric | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| fromNumeric | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** |
| 6 | * SPDX-FileCopyrightText: 2025 LibreCode coop and contributors |
| 7 | * SPDX-License-Identifier: AGPL-3.0-or-later |
| 8 | */ |
| 9 | |
| 10 | namespace OCA\Libresign\Enum; |
| 11 | |
| 12 | /** |
| 13 | * Signature flow modes |
| 14 | */ |
| 15 | enum SignatureFlow: string { |
| 16 | case NONE = 'none'; |
| 17 | case PARALLEL = 'parallel'; |
| 18 | case ORDERED_NUMERIC = 'ordered_numeric'; |
| 19 | |
| 20 | public const NUMERIC_NONE = 0; |
| 21 | public const NUMERIC_PARALLEL = 1; |
| 22 | public const NUMERIC_ORDERED_NUMERIC = 2; |
| 23 | |
| 24 | public function toNumeric(): int { |
| 25 | return match($this) { |
| 26 | self::NONE => self::NUMERIC_NONE, |
| 27 | self::PARALLEL => self::NUMERIC_PARALLEL, |
| 28 | self::ORDERED_NUMERIC => self::NUMERIC_ORDERED_NUMERIC, |
| 29 | }; |
| 30 | } |
| 31 | |
| 32 | public static function fromNumeric(int $value): self { |
| 33 | return match($value) { |
| 34 | self::NUMERIC_NONE => self::NONE, |
| 35 | self::NUMERIC_PARALLEL => self::PARALLEL, |
| 36 | self::NUMERIC_ORDERED_NUMERIC => self::ORDERED_NUMERIC, |
| 37 | default => throw new \ValueError("Invalid numeric value for SignatureFlow: $value"), |
| 38 | }; |
| 39 | } |
| 40 | } |