Neuron-PHP

IHttpResponse

Interface for HTTP response abstraction.

Represents the response from an HTTP request with status, body, headers, and error info.

Table of Contents

Methods

getBody()  : string
Get response body
getError()  : string
Get error message
getErrorCode()  : int
Get error code
getHeader()  : string|null
Get specific header value
getHeaders()  : array<string|int, mixed>
Get response headers
getStatusCode()  : int
Get HTTP status code
hasError()  : bool
Check if request had an error (connection error, timeout, etc.)
isSuccess()  : bool
Check if response is successful (2xx status code)

Methods

getBody()

Get response body

public getBody() : string
Return values
string

Response body content

getError()

Get error message

public getError() : string
Return values
string

Error message or empty string if no error

getErrorCode()

Get error code

public getErrorCode() : int
Return values
int

Error code or 0 if no error

getHeader()

Get specific header value

public getHeader(string $name) : string|null
Parameters
$name : string

Header name

Return values
string|null

Header value or null if not found

getHeaders()

Get response headers

public getHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>

Associative array of headers

getStatusCode()

Get HTTP status code

public getStatusCode() : int
Return values
int

HTTP status code (200, 404, 500, etc.)

hasError()

Check if request had an error (connection error, timeout, etc.)

public hasError() : bool
Return values
bool

True if error occurred

isSuccess()

Check if response is successful (2xx status code)

public isSuccess() : bool
Return values
bool

True if status code is 2xx


        
On this page

Search results