Index Documentation

FormContent
in package
implements IHttpContent

Represents form body content for a HTTP message.

Table of Contents

Interfaces

IHttpContent
Represents the body content for a HTTP message.

Methods

__construct()  : mixed
__toString()  : string
fromRaw()  : FormContent
Creates an instance from an array of form fields and uploaded files.
fromRequest()  : FormContent
Creates an instance from the $_POST and $_FILES superglobals.
getParam()  : mixed
Retrieves a form field with filtering.
getParams()  : array<string, mixed>
Gets all form fields.
getParamString()  : string
Gets all form fields as a query string.
getUploadedFile()  : HttpUploadedFile
Retrieves a file upload.
hasParam()  : bool
Checks if a form field is present.
hasUploadedFile()  : bool
Checks if a file upload is present.

Methods

__construct()

public __construct(array<string, mixed> $postFields, array<string, HttpUploadedFile|array<string, mixed>> $uploadedFiles) : mixed
Parameters
$postFields : array<string, mixed>

Form fields.

$uploadedFiles : array<string, HttpUploadedFile|array<string, mixed>>

Uploaded files.

__toString()

public __toString() : string
Return values
string

fromRaw()

Creates an instance from an array of form fields and uploaded files.

public static fromRaw(array<string, mixed> $post, array<string, mixed> $files) : FormContent
Parameters
$post : array<string, mixed>

Form fields.

$files : array<string, mixed>

Uploaded files.

Return values
FormContent

Instance representing the request body.

fromRequest()

Creates an instance from the $_POST and $_FILES superglobals.

public static fromRequest() : FormContent
Return values
FormContent

Instance representing the request body.

getParam()

Retrieves a form field with filtering.

public getParam(string $name[, int $filter = FILTER_DEFAULT ][, array<string, mixed>|int $options = 0 ]) : mixed
Parameters
$name : string

Name of the form field.

$filter : int = FILTER_DEFAULT

A PHP filter extension filter constant.

$options : array<string, mixed>|int = 0

Options for the PHP filter.

Return values
mixed

Value of the form field, null if not present.

getParams()

Gets all form fields.

public getParams() : array<string, mixed>
Return values
array<string, mixed>

Form fields.

getParamString()

Gets all form fields as a query string.

public getParamString([bool $spacesAsPlus = false ]) : string
Parameters
$spacesAsPlus : bool = false

true if spaces should be represented with a +, false if %20.

Return values
string

Query string representation of form fields.

getUploadedFile()

Retrieves a file upload.

public getUploadedFile(string $name) : HttpUploadedFile
Parameters
$name : string

Name of the form field.

Tags
throws
RuntimeException

If no uploaded file with form field $name is present.

Return values
HttpUploadedFile

Uploaded file info.

hasParam()

Checks if a form field is present.

public hasParam(string $name) : bool
Parameters
$name : string

Name of the form field.

Return values
bool

true if the field is present, false if not.

hasUploadedFile()

Checks if a file upload is present.

public hasUploadedFile(string $name) : bool
Parameters
$name : string

Name of the form field.

Return values
bool

true if the upload is present, false if not.


        
On this page

Search results