Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| FieldPermissionType | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
| isEditable | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isVisible | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| isHidden | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Modules\Profiles\Domain\Model; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | /** |
| 12 | * Field Permission Type Enum. |
| 13 | * |
| 14 | * Defines the access level for a specific field within a permission profile. |
| 15 | * |
| 16 | * @package App\Modules\Profiles\Domain\Model |
| 17 | */ |
| 18 | enum FieldPermissionType: string |
| 19 | { |
| 20 | case EDIT = 'edit'; |
| 21 | case VIEW = 'view'; |
| 22 | case HIDE = 'hide'; |
| 23 | |
| 24 | /** |
| 25 | * Checks whether the field is editable (read/write). |
| 26 | * |
| 27 | * @return bool True if field is editable. |
| 28 | */ |
| 29 | public function isEditable(): bool |
| 30 | { |
| 31 | return $this === self::EDIT; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Checks whether the field is visible (view or edit). |
| 36 | * |
| 37 | * @return bool True if field can be seen. |
| 38 | */ |
| 39 | public function isVisible(): bool |
| 40 | { |
| 41 | return $this === self::EDIT || $this === self::VIEW; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Checks whether the field is hidden. |
| 46 | * |
| 47 | * @return bool True if field is hidden. |
| 48 | */ |
| 49 | public function isHidden(): bool |
| 50 | { |
| 51 | return $this === self::HIDE; |
| 52 | } |
| 53 | } |