Result
Result
Authentication outcome value object.
class Result implements \JsonSerializableImplements: JsonSerializable
Encapsulates the result of an authentication attempt, including whether the attempt succeeded, the resolved identity (if any), optional message text, and arbitrary payload data associated with the auth process.
The object is JSON-serializable for direct use in API responses and other transport layers that need a structured auth result contract.
Properties
success
Indicates whether authentication was successful.
public bool $successType: bool
identity
public string $identityType: string
token
public TokenPair $tokenType: Hazaar\Auth\TokenPair
message
Human-readable status or failure message.
public string $messageType: string
data
public array $dataType: array
Methods
__construct
public __construct(bool $success, ?string $identity, array $data): voidParameters
| Parameter | Type | Description |
|---|---|---|
$success | bool | Whether authentication was successful |
$identity | string | The authenticated identity (e.g., user ID), or null if authentication failed |
$data | array | Additional data associated with the authentication result |
success
Creates a successful authentication result.
public success(string $identity, array $data): selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$identity | string | the authenticated user's identity |
$data | array |
failure
Creates a failed authentication result with the provided error message.
public failure(string $message): selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$message | string | the failure message to associate with the result |
jsonSerialize
Specifies data which should be serialized to JSON.
public jsonSerialize(): arrayReturns: array
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000