Radiate\Http\Request

Implements

Properties

$request

The request attributes

protected array $request

$cookies

The cookie attributes

protected array $cookies

$files

The file attributes

protected array $files

$server

The server attributes

protected array $server

$headers

The header attributes

protected array $headers

$userResolver

The user resolver

protected \Closure $userResolver

Methods

__construct

Create the request instance

public function __construct(array $request = [], array $cookies = [], array $files = [], array $server = []): void

Properties

  • $request Usually the global $_REQUEST array
  • $cookies Usually the global $_COOKIE array
  • $files Usually the global $_FILES array
  • $server Usually the global $_SERVER array

capture

Capture the global request

public static function capture(): Request

createFrom

Create a new request from this one

public static function createFrom(self $from, ?Request $to = null): Request

Properties

  • $from The request to create from
  • $to The request to create to

server

Get a server attribute

public function server(string $key, mixed $default = null): mixed

Properties

  • $key The key of the server entry to return
  • $default The fallback if the entry doesn't exist

Get a header

public function header(string $key, mixed $default = null): mixed

Properties

  • $key The key of the header to return
  • $default The fallback if the header doesn't exist

isMethod

Determine if the method matches the given method

public function isMethod(string $method): bool

Properties

  • $method The method to check against

method

Get the intended method

public function method(): string

realMethod

Get the real request method

public function realMethod(): string

merge

Merge the attributes into the request

public function merge(array $attributes): self

Properties

  • $attributes The attributes to merge into the request

ajax

Determine if the request was made with AJAX

public function ajax(): bool

wantsJson

Determine if the request can accept a JSON response

public function wantsJson(): bool

expectsJson

Determine if the request expects a JSON response

public function expectsJson(): bool

has

Determine if the attribute exists

public function has(string $key): bool

Properties

  • $key The key to check on the request

get

Get an attribute or fallback

public function get(string $key, $default = null): mixed

Properties

  • $key The key to get
  • $key The fallback if the entry doesn't exist

add

Add an attribute to the request

public function add(string $key, mixed $value): void

Properties

  • $key The key to add
  • $value The value to set in the request

remove

Remove the attribute from the request

public function remove(string $key): void

Properties

  • $key The key to remove

user

Get the request user

See the AuthManager class for more information

public function user(): \WP_User|false

setUserResolver

Set the user resolver

public function setUserResolver(\Closure $resolver): self

Properties

  • $resolver The user resolver

getUserResolver

Set the user resolver

public function getUserResolver(): \Closure

all

Return the object as an array

public function all(): array

toArray

Return the object as an array

public function toArray(): array

toJson

Return the object as a json string

public function toJson(): string

__toString

Return the object as a json string

public function __toString(): string

__isset

Determine if the attribute exists

public function __isset(string $key): bool

Properties

  • $key The key to check on the request

__get

Get an attribute

public function __get(string $key): mixed

Properties

  • $key The key to get

__set

Add an attribute to the request

public function __set(string $key, mixed $value): void

Properties

  • $key The key to set
  • $value The value to set