Skip to content

Response

Class to handle OAuth2 Responses in a graceful way. Use this interface to output the proper OAuth2 responses.

See Also:

  • \OAuth2\OAuth2\ResponseInterface - This class borrows heavily from the Symfony2 Framework and is part of the symfony package
  • \OAuth2\Symfony\Component\HttpFoundation\Request - (https://github.com/symfony/symfony)

Properties

version

public string $version

statusCode

protected int $statusCode

statusText

protected string $statusText

parameters

protected array $parameters

httpHeaders

protected array $httpHeaders

statusTexts

public static array $statusTexts
  • This property is static.

Methods

__construct

public __construct(array $parameters = array(), int $statusCode = 200, array $headers = array()): mixed

Parameters:

Parameter Type Description
$parameters array
$statusCode int
$headers array

__toString

Converts the response object to string containing all headers and the response content.

public __toString(): string

Return Value:

The response with headers and content


buildHeader

Returns the build header line.

protected buildHeader(string $name, string $value): string

Parameters:

Parameter Type Description
$name string The header name
$value string The header value

Return Value:

The built header line


getStatusCode

public getStatusCode(): int

setStatusCode

public setStatusCode(int $statusCode, string $text = null): mixed

Parameters:

Parameter Type Description
$statusCode int
$text string

Throws:


getStatusText

public getStatusText(): string

getParameters

public getParameters(): array

setParameters

public setParameters(array $parameters): mixed

Parameters:

Parameter Type Description
$parameters array

addParameters

public addParameters(array $parameters): mixed

Parameters:

Parameter Type Description
$parameters array

getParameter

public getParameter(string $name, mixed $default = null): mixed

Parameters:

Parameter Type Description
$name string
$default mixed

setParameter

public setParameter(string $name, mixed $value): mixed

Parameters:

Parameter Type Description
$name string
$value mixed

setHttpHeaders

public setHttpHeaders(array $httpHeaders): mixed

Parameters:

Parameter Type Description
$httpHeaders array

setHttpHeader

public setHttpHeader(string $name, mixed $value): mixed

Parameters:

Parameter Type Description
$name string
$value mixed

addHttpHeaders

public addHttpHeaders(array $httpHeaders): mixed

Parameters:

Parameter Type Description
$httpHeaders array

getHttpHeaders

public getHttpHeaders(): array

getHttpHeader

public getHttpHeader(string $name, mixed $default = null): mixed

Parameters:

Parameter Type Description
$name string
$default mixed

getResponseBody

public getResponseBody(string $format = 'json'): mixed

Parameters:

Parameter Type Description
$format string

Throws:


send

public send(string $format = 'json'): mixed

Parameters:

Parameter Type Description
$format string

setError

public setError(int $statusCode, string $error, string $errorDescription = null, string $errorUri = null): mixed

Parameters:

Parameter Type Description
$statusCode int
$error string
$errorDescription string
$errorUri string

Throws:


setRedirect

public setRedirect(int $statusCode, string $url, string $state = null, string $error = null, string $errorDescription = null, string $errorUri = null): mixed

Parameters:

Parameter Type Description
$statusCode int
$url string
$state string
$error string
$errorDescription string
$errorUri string

Throws:


isInvalid

public isInvalid(): bool

See Also:

  • http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html -

isInformational

public isInformational(): bool

isSuccessful

public isSuccessful(): bool

isRedirection

public isRedirection(): bool

isClientError

public isClientError(): bool

isServerError

public isServerError(): bool

getHttpHeadersAsString

Function from Symfony2 HttpFoundation - output pretty header

private getHttpHeadersAsString(array $headers): string

Parameters:

Parameter Type Description
$headers array

beautifyHeaderName

Function from Symfony2 HttpFoundation - output pretty header

private beautifyHeaderName(string $name): mixed

Parameters:

Parameter Type Description
$name string

beautifyCallback

Function from Symfony2 HttpFoundation - output pretty header

private beautifyCallback(array $match): string

Parameters:

Parameter Type Description
$match array


Automatically generated on 2025-03-18