trait HasBody

Every request and pending request uses this trait, so body traits need no upstream HasBody contract or ChecksForHasBody check.

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, keeping any existing multipart values.

attach(array|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 36
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 55
HasBody asJson(array $data = [])

Use a JSON request body.

Parameters

array $data

Return Value

HasBody

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

Use a URL-encoded form request body.

Parameters

array $data

Return Value

HasBody

at line 80
HasBody asMultipart()

Use a multipart request body, keeping any existing multipart values.

Return Value

HasBody

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

Attach a multipart value to the request.

Parameters

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

Return Value

HasBody

at line 129
HasBody withData(array $data)

Merge structured values into the request body.

A multipart body receives each value as an appended field.

Parameters

array $data

Return Value

HasBody

at line 154
mixed body()

Get the resolved request body value.

Return Value

mixed

at line 162
bool hasBody()

Determine if the request has a body repository.

Return Value

bool

at line 172
final BodyRepository|null copyBodyRepository()

internal  
 

Copy the body repository for a pending request.

Return Value

BodyRepository|null

at line 182
protected BodyRepository|null defaultBodyRepository()

Resolve the default body repository.

Return Value

BodyRepository|null

at line 190
protected BodyRepository|null bodyRepository()

Get the request body repository.

Return Value

BodyRepository|null