Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| CertificateType | |
0.00% |
0 / 8 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 1 |
| isCA | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| isRoot | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isLeaf | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getDescription | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| 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 | enum CertificateType: string { |
| 13 | case ROOT = 'root'; |
| 14 | case INTERMEDIATE = 'intermediate'; |
| 15 | case LEAF = 'leaf'; |
| 16 | |
| 17 | public function isCA(): bool { |
| 18 | return $this === self::ROOT || $this === self::INTERMEDIATE; |
| 19 | } |
| 20 | |
| 21 | public function isRoot(): bool { |
| 22 | return $this === self::ROOT; |
| 23 | } |
| 24 | |
| 25 | public function isLeaf(): bool { |
| 26 | return $this === self::LEAF; |
| 27 | } |
| 28 | |
| 29 | public function getDescription(): string { |
| 30 | return match($this) { |
| 31 | self::ROOT => 'Root Certificate (CA)', |
| 32 | self::INTERMEDIATE => 'Intermediate Certificate (CA)', |
| 33 | self::LEAF => 'User Certificate', |
| 34 | }; |
| 35 | } |
| 36 | } |