trait HasBody

Properties

protected BodyRepository|null $bodyRepository

The request body repository.

Methods

withBody(mixed $content, string|null $contentType = 'application/json')

Set the raw request body.

asJson(array $data = [])

Use a JSON request body.

asForm(array $data = [])

Use a URL-encoded form request body.

asMultipart()

Use a multipart request body.

attach(string $name, mixed $contents = '', string|null $filename = null, array $headers = [])

Attach a multipart value to the request.

withData(array $data)

Merge structured values into the request body.

mixed
body()

Get the resolved request body value.

bool
hasBody()

Determine if the request has a body repository.

copyBodyRepository()

Copy the body repository for a pending request.

defaultBodyRepository()

Resolve the default body repository.

bodyRepository()

Get the request body repository.

Details

at line 31
HasBody withBody(mixed $content, string|null $contentType = 'application/json')

Set the raw request body.

Parameters

mixed $content
string|null $contentType

Return Value

HasBody

at line 50
HasBody asJson(array $data = [])

Use a JSON request body.

Parameters

array $data

Return Value

HasBody

at line 63
HasBody asForm(array $data = [])

Use a URL-encoded form request body.

Parameters

array $data

Return Value

HasBody

at line 75
HasBody asMultipart()

Use a multipart request body.

Return Value

HasBody

at line 89
HasBody attach(string $name, mixed $contents = '', string|null $filename = null, array $headers = [])

Attach a multipart value to the request.

Parameters

string $name
mixed $contents
string|null $filename
array $headers

Return Value

HasBody

at line 112
HasBody withData(array $data)

Merge structured values into the request body.

Parameters

array $data

Return Value

HasBody

at line 129
mixed body()

Get the resolved request body value.

Return Value

mixed

at line 137
bool hasBody()

Determine if the request has a body repository.

Return Value

bool

at line 147
final BodyRepository|null copyBodyRepository()

internal  
 

Copy the body repository for a pending request.

Return Value

BodyRepository|null

at line 157
protected BodyRepository|null defaultBodyRepository()

Resolve the default body repository.

Return Value

BodyRepository|null

at line 165
protected BodyRepository|null bodyRepository()

Get the request body repository.

Return Value

BodyRepository|null