PHP Class Larabros\Elogram\Http\Response

Afficher le fichier Open project: larabros/elogram Class Usage Examples

Protected Properties

Свойство Type Description
$data array
$meta array
$pagination array
$raw array

Méthodes publiques

Méthode Description
__construct ( array $meta = [], array $data = [], array $pagination = [] ) Creates a new instance of :php:class:Response.
__toString ( ) : string Returns the JSON-encoded raw response.
createFromJson ( array $response ) : static Creates a new instance of :php:class:Response from a JSON-decoded response body.
get ( ) : array | Collection Gets the response body. If the response contains multiple records, a Collection is returned.
getRaw ( string | null $key = null ) : array Gets the JSON-decoded raw response.
hasPages ( ) : boolean If the response has a pagination field with a next_url key, then returns true, otherwise false.
merge ( Response $response ) : Response Merges the contents of this response with $response and returns a new :php:class:Response instance.
nextUrl ( ) : string | null Returns the next URL, if available, otherwise null.

Méthodes protégées

Méthode Description
isCollection ( array | Collection $data ) : boolean Tests the current response data to see if one or more records were returned.
isRecord ( array | Collection $data ) : boolean Tests the current response data to see if a single record was returned.

Method Details

__construct() public méthode

Creates a new instance of :php:class:Response.
public __construct ( array $meta = [], array $data = [], array $pagination = [] )
$meta array
$data array
$pagination array

__toString() public méthode

Returns the JSON-encoded raw response.
public __toString ( ) : string
Résultat string

createFromJson() public static méthode

Creates a new instance of :php:class:Response from a JSON-decoded response body.
public static createFromJson ( array $response ) : static
$response array
Résultat static

get() public méthode

Gets the response body. If the response contains multiple records, a Collection is returned.
public get ( ) : array | Collection
Résultat array | Illuminate\Support\Collection

getRaw() public méthode

Gets the JSON-decoded raw response.
public getRaw ( string | null $key = null ) : array
$key string | null
Résultat array

hasPages() public méthode

If the response has a pagination field with a next_url key, then returns true, otherwise false.
public hasPages ( ) : boolean
Résultat boolean

isCollection() protected méthode

Tests the current response data to see if one or more records were returned.
protected isCollection ( array | Collection $data ) : boolean
$data array | Illuminate\Support\Collection
Résultat boolean

isRecord() protected méthode

Tests the current response data to see if a single record was returned.
protected isRecord ( array | Collection $data ) : boolean
$data array | Illuminate\Support\Collection
Résultat boolean

merge() public méthode

Merges the contents of this response with $response and returns a new :php:class:Response instance.
public merge ( Response $response ) : Response
$response Response
Résultat Response

nextUrl() public méthode

Returns the next URL, if available, otherwise null.
public nextUrl ( ) : string | null
Résultat string | null

Property Details

$data protected_oe property

protected array $data
Résultat array

$meta protected_oe property

protected array $meta
Résultat array

$pagination protected_oe property

protected array $pagination
Résultat array

$raw protected_oe property

protected array $raw
Résultat array