28 lines
605 B
PHP
28 lines
605 B
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
enum LoginError
|
|
{
|
|
case INVALID_CREDENTIALS;
|
|
case SERVER_ERROR;
|
|
|
|
public function httpStatusCode(): int
|
|
{
|
|
return match ($this) {
|
|
self::INVALID_CREDENTIALS => Response::HTTP_UNAUTHORIZED,
|
|
self::SERVER_ERROR => Response::HTTP_INTERNAL_SERVER_ERROR,
|
|
};
|
|
}
|
|
|
|
public function message(): string
|
|
{
|
|
return match ($this) {
|
|
self::INVALID_CREDENTIALS => 'Invalid credentials',
|
|
self::SERVER_ERROR => 'Authentication failed',
|
|
};
|
|
}
|
|
}
|