30 lines
535 B
PHP
30 lines
535 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Data\Auth;
|
|
|
|
use App\Enums\LoginError;
|
|
use App\Models\User;
|
|
|
|
final readonly class LoginResult
|
|
{
|
|
public function __construct(
|
|
public ?User $user,
|
|
public ?string $token,
|
|
public ?LoginError $error = null
|
|
) {
|
|
}
|
|
|
|
public static function success(User $user, string $token): self
|
|
{
|
|
return new self($user, $token, null);
|
|
}
|
|
|
|
public static function error(LoginError $error): self
|
|
{
|
|
return new self(null, null, $error);
|
|
}
|
|
|
|
}
|