PHP Класс Flugg\Responder\Http\ResponseBuilder

Автор: Alexander Tømmerås ([email protected])
Наследование: implements Illuminate\Contracts\Support\Arrayable, implements Illuminate\Contracts\Support\Jsonable, implements JsonSerializabl\JsonSerializable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$includeStatusCode boolean Flag indicating if status code should be added to the serialized data.
$responseFactory Illuminate\Contracts\Routing\ResponseFactory | Laravel\Lumen\Http\ResponseFactory Response factory used to generate JSON responses.
$statusCode integer The HTTP status code for the response.

Открытые методы

Метод Описание
__construct ( Illuminate\Contracts\Routing\ResponseFactory | ResponseFactory $responseFactory ) Constructor.
jsonSerialize ( ) : array Convert the object into something JSON serializable.
respond ( integer $statusCode = null, array $headers = [] ) : Illuminate\Http\JsonResponse Serialize the data and wrap it in a JSON response object.
setIncludeStatusCode ( boolean $includeStatusCode ) : ResponseBuilder Set a flag indicating if status code should be added to the response.
setStatus ( integer $statusCode ) : ResponseBuilder Set the HTTP status code for the response.
toArray ( ) : array Convert the response to an array.
toCollection ( ) : Collection Convert the response to an Illuminate collection.
toJson ( integer $options ) : string Convert the response to JSON.

Защищенные методы

Метод Описание
includeStatusCode ( array $data ) : array Include a status code to the serialized data if enabled.

Описание методов

__construct() публичный Метод

Constructor.
public __construct ( Illuminate\Contracts\Routing\ResponseFactory | ResponseFactory $responseFactory )
$responseFactory Illuminate\Contracts\Routing\ResponseFactory | Laravel\Lumen\Http\ResponseFactory

includeStatusCode() защищенный Метод

Include a status code to the serialized data if enabled.
protected includeStatusCode ( array $data ) : array
$data array
Результат array

jsonSerialize() публичный Метод

Convert the object into something JSON serializable.
public jsonSerialize ( ) : array
Результат array

respond() публичный Метод

Serialize the data and wrap it in a JSON response object.
public respond ( integer $statusCode = null, array $headers = [] ) : Illuminate\Http\JsonResponse
$statusCode integer
$headers array
Результат Illuminate\Http\JsonResponse

setIncludeStatusCode() публичный Метод

Set a flag indicating if status code should be added to the response.
public setIncludeStatusCode ( boolean $includeStatusCode ) : ResponseBuilder
$includeStatusCode boolean
Результат ResponseBuilder

setStatus() публичный Метод

Set the HTTP status code for the response.
public setStatus ( integer $statusCode ) : ResponseBuilder
$statusCode integer
Результат ResponseBuilder

toArray() абстрактный публичный Метод

Convert the response to an array.
abstract public toArray ( ) : array
Результат array

toCollection() публичный Метод

Convert the response to an Illuminate collection.
public toCollection ( ) : Collection
Результат Illuminate\Support\Collection

toJson() публичный Метод

Convert the response to JSON.
public toJson ( integer $options ) : string
$options integer
Результат string

Описание свойств

$includeStatusCode защищенное свойство

Flag indicating if status code should be added to the serialized data.
protected bool $includeStatusCode
Результат boolean

$responseFactory защищенное свойство

Response factory used to generate JSON responses.
protected ResponseFactory,Illuminate\Contracts\Routing|ResponseFactory,Laravel\Lumen\Http $responseFactory
Результат Illuminate\Contracts\Routing\ResponseFactory | Laravel\Lumen\Http\ResponseFactory

$statusCode защищенное свойство

The HTTP status code for the response.
protected int $statusCode
Результат integer