$identity] : null, ); } // ========================================================================= // Status Checks // ========================================================================= public function isSuccess(): bool { return $this->status === self::STATUS_SUCCESS; } public function isPending(): bool { return $this->status === self::STATUS_PENDING; } public function isRedirect(): bool { return $this->status === self::STATUS_REDIRECT; } public function isFailed(): bool { return $this->status === self::STATUS_FAILED; } public function hasTokens(): bool { return $this->tokens !== null && !empty($this->tokens); } // ========================================================================= // Serialization // ========================================================================= /** * Convert to array for JSON response */ public function toArray(): array { $result = ['status' => $this->status]; if ($this->sessionId !== null) { $result['session'] = $this->sessionId; } if ($this->sessionState !== null) { $result['state'] = $this->sessionState; } if ($this->user !== null) { $result['user'] = $this->user; } if ($this->methods !== null) { $result['methods'] = $this->methods; } if ($this->challenge !== null) { $result['challenge'] = $this->challenge; } if ($this->redirectUrl !== null) { $result['redirect_url'] = $this->redirectUrl; } if ($this->returnUrl !== null) { $result['return_url'] = $this->returnUrl; } if ($this->errorCode !== null) { $result['error_code'] = $this->errorCode; } if ($this->errorMessage !== null) { $result['error'] = $this->errorMessage; } return $result; } }