Documentation

InteractsWithContentTypes

Table of Contents

accepts()  : bool
Determines whether the current requests accepts a given content type.
acceptsHtml()  : bool
Determines whether a request accepts HTML.
acceptsJson()  : bool
Determines whether a request accepts JSON.
expectsJson()  : bool
Determine if the current request probably expects a JSON response.
format()  : string
Get the data format expected in the response.
isJson()  : bool
Determine if the request is sending JSON.
matchesType()  : bool
Determine if the given content types match.
prefers()  : string|null
Return the most suitable content type from the given array based on content negotiation.
wantsJson()  : bool
Determine if the current request is asking for JSON in return.

Methods

accepts()

Determines whether the current requests accepts a given content type.

public accepts(string|array<string|int, mixed> $contentTypes) : bool
Parameters
$contentTypes : string|array<string|int, mixed>
Return values
bool

acceptsHtml()

Determines whether a request accepts HTML.

public acceptsHtml() : bool
Return values
bool

acceptsJson()

Determines whether a request accepts JSON.

public acceptsJson() : bool
Return values
bool

expectsJson()

Determine if the current request probably expects a JSON response.

public expectsJson() : bool
Return values
bool

format()

Get the data format expected in the response.

public format([string $default = 'html' ]) : string
Parameters
$default : string = 'html'
Return values
string

matchesType()

Determine if the given content types match.

public static matchesType(string $actual, string $type) : bool
Parameters
$actual : string
$type : string
Return values
bool

prefers()

Return the most suitable content type from the given array based on content negotiation.

public prefers(string|array<string|int, mixed> $contentTypes) : string|null
Parameters
$contentTypes : string|array<string|int, mixed>
Return values
string|null

wantsJson()

Determine if the current request is asking for JSON in return.

public wantsJson() : bool
Return values
bool

Search results