Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
AuthFailureReason
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
7
100.00% covered (success)
100.00%
1 / 1
 label
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
7
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Modules\User\Domain\Model;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11/**
12 * Authentication Failure and Success Status Codes.
13 *
14 * Defines integer codes representing authentication attempt outcomes
15 * and maps them to human-readable message keys.
16 *
17 * @package App\Modules\User\Domain\Model
18 */
19enum AuthFailureReason: int
20{
21    case BLOCKED_IP = 0;
22    case INVALID_LOGIN = 1;
23    case INVALID_PASSWORD = 2;
24    case INVALID_MFA = 3;
25    case BLOCKED_ACCOUNT = 4;
26    case SUCCESS = 9;
27
28    /**
29     * Gets human-readable description message for failure reason code.
30     *
31     * @return string Description label.
32     */
33    public function label(): string
34    {
35        return match ($this) {
36            self::BLOCKED_IP => 'IP address blocked',
37            self::INVALID_LOGIN => 'Invalid login or user not found',
38            self::INVALID_PASSWORD => 'Invalid password',
39            self::INVALID_MFA => 'Invalid MFA code',
40            self::BLOCKED_ACCOUNT => 'Account temporarily locked due to multiple failed attempts',
41            self::SUCCESS => 'Logged in successfully',
42        };
43    }
44}