Response
extends Message
in package
implements
ResponseInterface
Class Response.
Table of Contents
Interfaces
- ResponseInterface
- Interface ResponseInterface.
Properties
- $body : string
- HTTP Message Body.
- $cookies : array<string, Cookie>
- HTTP Message Cookies.
- $headers : array<string, string>
- HTTP Message Headers.
- $info : array<string|int, mixed>
- Response curl info.
- $jsonFlags : int
- $method : string
- HTTP Request Method.
- $protocol : string
- HTTP Message Protocol.
- $request : Request
- $statusCode : int
- HTTP Response Status Code.
- $statusReason : string
- $url : URL
- HTTP Request URL.
Methods
- __construct() : mixed
- Response constructor.
- __toString() : string
- getBody() : string
- Get the Message body.
- getCookie() : Cookie|null
- Get a Cookie by name.
- getCookies() : array<string, Cookie>
- Get all Cookies.
- getHeader() : string|null
- getHeaderLine() : string|null
- getHeaderLines() : array<int, string>
- getHeaders() : array<string, string>
- getInfo() : array<string|int, mixed>
- getJson() : array<string, mixed>|false|object
- Get body as decoded JSON.
- getJsonFlags() : int
- Get JSON flags.
- getLinks() : array<string, string>
- Get parsed Link header as array.
- getProtocol() : string
- Get the HTTP protocol.
- getRequest() : Request
- getStartLine() : string
- Get the Message Start-Line.
- getStatus() : string
- getStatusCode() : int
- Get the status code.
- getStatusReason() : string
- hasCookie() : bool
- Say if the Message has a Cookie.
- hasHeader() : bool
- isJson() : bool
- isStatusCode() : bool
- parseQualityValues() : array<string, float>
- setJsonFlags() : static
- Set JSON flags.
- appendHeader() : static
- Append a Message header.
- getMethod() : string
- Gets the HTTP Request Method.
- getUrl() : URL
- Gets the requested URL.
- isMethod() : bool
- parseContentType() : string|null
- parseLinkHeader() : array<string, string>
- removeCookie() : static
- Remove a Cookie by name.
- removeCookies() : static
- Remove many Cookies by names.
- removeHeader() : static
- Remove a header by name.
- removeHeaders() : static
- Remove all headers.
- removeHeadersByNames() : static
- Remove headers by names.
- setBody() : static
- Set the Message body.
- setCookie() : static
- Set a new Cookie.
- setCookies() : static
- Set a list of Cookies.
- setHeader() : static
- Set a Message header.
- setHeaders() : static
- Set a list of headers.
- setMethod() : static
- Set the request method.
- setProtocol() : static
- Set the HTTP protocol.
- setStatusCode() : static
- setStatusReason() : static
- setUrl() : static
- Set the Message URL.
Properties
$body
HTTP Message Body.
protected
string
$body
$cookies
HTTP Message Cookies.
protected
array<string, Cookie>
$cookies
= []
$headers
HTTP Message Headers.
protected
array<string, string>
$headers
= []
$info
Response curl info.
protected
array<string|int, mixed>
$info
= []
$jsonFlags
protected
int
$jsonFlags
= 0
$method
HTTP Request Method.
protected
string
$method
$protocol
HTTP Message Protocol.
protected
string
$protocol
$request
protected
Request
$request
$statusCode
HTTP Response Status Code.
protected
int
$statusCode
$statusReason
protected
string
$statusReason
$url
HTTP Request URL.
protected
URL
$url
Methods
__construct()
Response constructor.
public
__construct(Request $request, string $protocol, int $status, string $reason, array<string, array<int, string>> $headers, string $body[, array<string|int, mixed> $info = [] ]) : mixed
Parameters
- $request : Request
- $protocol : string
- $status : int
- $reason : string
- $headers : array<string, array<int, string>>
- $body : string
- $info : array<string|int, mixed> = []
__toString()
public
__toString() : string
Return values
stringgetBody()
Get the Message body.
public
getBody() : string
Attributes
- #[Pure]
Return values
stringgetCookie()
Get a Cookie by name.
public
getCookie(string $name) : Cookie|null
Parameters
- $name : string
Attributes
- #[Pure]
Return values
Cookie|nullgetCookies()
Get all Cookies.
public
getCookies() : array<string, Cookie>
Attributes
- #[Pure]
Return values
array<string, Cookie>getHeader()
public
getHeader(string $name) : string|null
Parameters
- $name : string
Attributes
- #[Pure]
Return values
string|nullgetHeaderLine()
public
getHeaderLine(string $name) : string|null
Parameters
- $name : string
Attributes
- #[Pure]
Return values
string|nullgetHeaderLines()
public
getHeaderLines() : array<int, string>
Attributes
- #[Pure]
Return values
array<int, string>getHeaders()
public
getHeaders() : array<string, string>
Attributes
- #[Pure]
Return values
array<string, string>getInfo()
public
getInfo() : array<string|int, mixed>
Attributes
- #[ArrayShape]
- ['appconnect_time_us' => 'int', 'certinfo' => 'array', 'connect_time' => 'float', 'connect_time_us' => 'int', 'content_type' => 'string', 'download_content_length' => 'float', 'effective_method' => 'string', 'filetime' => 'int', 'header_size' => 'int', 'http_code' => 'int', 'http_version' => 'int', 'local_ip' => 'string', 'local_port' => 'int', 'namelookup_time' => 'float', 'namelookup_time_us' => 'int', 'pretransfer_time' => 'float', 'pretransfer_time_us' => 'int', 'primary_ip' => 'string', 'primary_port' => 'int', 'protocol' => 'int', 'redirect_count' => 'int', 'redirect_time' => 'float', 'redirect_time_us' => 'int', 'redirect_url' => 'string', 'request_size' => 'int', 'scheme' => 'string', 'size_download' => 'float', 'size_upload' => 'float', 'speed_download' => 'float', 'speed_upload' => 'float', 'ssl_verify_result' => 'int', 'ssl_verifyresult' => 'int', 'starttransfer_time' => 'float', 'starttransfer_time_us' => 'int', 'total_time' => 'float', 'total_time_us' => 'int', 'upload_content_length' => 'float', 'url' => 'string']
Return values
array<string|int, mixed>getJson()
Get body as decoded JSON.
public
getJson([bool $assoc = false ][, int|null $flags = null ][, int<1, max> $depth = 512 ]) : array<string, mixed>|false|object
Parameters
- $assoc : bool = false
- $flags : int|null = null
-
[optional]
Bitmask consisting of JSON_BIGINT_AS_STRING, JSON_INVALID_UTF8_IGNORE, JSON_INVALID_UTF8_SUBSTITUTE, JSON_OBJECT_AS_ARRAY, JSON_THROW_ON_ERROR.
Default is none when null.
- $depth : int<1, max> = 512
Tags
Return values
array<string, mixed>|false|objectgetJsonFlags()
Get JSON flags.
public
getJsonFlags() : int
Tags
Return values
intgetLinks()
Get parsed Link header as array.
public
getLinks() : array<string, string>
NOTE: To be parsed, links must be in the GitHub REST API format.
Tags
Return values
array<string, string> —Associative array with rel as keys and links as values
getProtocol()
Get the HTTP protocol.
public
getProtocol() : string
Attributes
- #[Pure]
Return values
stringgetRequest()
public
getRequest() : Request
Return values
RequestgetStartLine()
Get the Message Start-Line.
public
getStartLine() : string
Tags
Return values
stringgetStatus()
public
getStatus() : string
Attributes
- #[Pure]
Return values
stringgetStatusCode()
Get the status code.
public
getStatusCode() : int
Attributes
- #[Override]
- #[Pure]
Return values
intgetStatusReason()
public
getStatusReason() : string
Attributes
- #[Pure]
Return values
stringhasCookie()
Say if the Message has a Cookie.
public
hasCookie(string $name) : bool
Parameters
- $name : string
-
Cookie name
Attributes
- #[Pure]
Return values
boolhasHeader()
public
hasHeader(string $name[, string|null $value = null ]) : bool
Parameters
- $name : string
- $value : string|null = null
Attributes
- #[Pure]
Return values
boolisJson()
public
isJson() : bool
Attributes
- #[Pure]
Return values
boolisStatusCode()
public
isStatusCode(int $code) : bool
Parameters
- $code : int
Tags
Attributes
- #[Override]
Return values
boolparseQualityValues()
public
static parseQualityValues(string|null $string) : array<string, float>
Parameters
- $string : string|null
Tags
Return values
array<string, float>setJsonFlags()
Set JSON flags.
public
setJsonFlags(int $flags) : static
Parameters
- $flags : int
Tags
Return values
staticappendHeader()
Append a Message header.
protected
appendHeader(string $name, string $value) : static
Used to set repeated header field names.
Parameters
- $name : string
- $value : string
Tags
Return values
staticgetMethod()
Gets the HTTP Request Method.
protected
getMethod() : string
Attributes
- #[Pure]
Return values
string —$method One of: CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, or TRACE
getUrl()
Gets the requested URL.
protected
getUrl() : URL
Attributes
- #[Pure]
Return values
URLisMethod()
protected
isMethod(string $method) : bool
Parameters
- $method : string
Tags
Return values
boolparseContentType()
protected
parseContentType() : string|null
Attributes
- #[Pure]
Return values
string|nullparseLinkHeader()
protected
parseLinkHeader(string $headerLink) : array<string, string>
Parameters
- $headerLink : string
Return values
array<string, string>removeCookie()
Remove a Cookie by name.
protected
removeCookie(string $name) : static
Parameters
- $name : string
Return values
staticremoveCookies()
Remove many Cookies by names.
protected
removeCookies(array<int, string> $names) : static
Parameters
- $names : array<int, string>
Return values
staticremoveHeader()
Remove a header by name.
protected
removeHeader(string $name) : static
Parameters
- $name : string
Return values
staticremoveHeaders()
Remove all headers.
protected
removeHeaders() : static
Return values
staticremoveHeadersByNames()
Remove headers by names.
protected
removeHeadersByNames(array<string|int, string> $names) : static
Parameters
- $names : array<string|int, string>
Return values
staticsetBody()
Set the Message body.
protected
setBody(string $body) : static
Parameters
- $body : string
Return values
staticsetCookie()
Set a new Cookie.
protected
setCookie(Cookie $cookie) : static
Parameters
- $cookie : Cookie
Return values
staticsetCookies()
Set a list of Cookies.
protected
setCookies(array<int, Cookie> $cookies) : static
Parameters
- $cookies : array<int, Cookie>
Return values
staticsetHeader()
Set a Message header.
protected
setHeader(string $name, string $value) : static
Parameters
- $name : string
- $value : string
Tags
Attributes
- #[Override]
Return values
staticsetHeaders()
Set a list of headers.
protected
setHeaders(array<string, string> $headers) : static
Parameters
- $headers : array<string, string>
Return values
staticsetMethod()
Set the request method.
protected
setMethod(string $method) : static
Parameters
- $method : string
-
One of: CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, or TRACE
Tags
Return values
staticsetProtocol()
Set the HTTP protocol.
protected
setProtocol(string $protocol) : static
Parameters
- $protocol : string
-
HTTP/1.1, HTTP/2, etc
Return values
staticsetStatusCode()
protected
setStatusCode(int $code) : static
Parameters
- $code : int
Return values
staticsetStatusReason()
protected
setStatusReason(string $statusReason) : static
Parameters
- $statusReason : string
Return values
staticsetUrl()
Set the Message URL.
protected
setUrl(URL|string $url) : static
Parameters
- $url : URL|string