FormDataProcessor
in package
FormDataProcessor Class Doc Comment.
Tags
Table of Contents
Properties
- $has_file : bool
- Tags whether payload passed to ::prepare() contains one or more SplFileObject or stream values.
Methods
- flatten() : array<string|int, mixed>
- Flattens a multi-level array of data and generates a single-level array compatible with formdata - a single-level array where the keys use bracket notation to signify nested data.
- prepare() : array<string|int, mixed>
- Take value and turn it into an array suitable for inclusion in the http body (form parameter). If it's a string, pass through unchanged If it's a datetime object, format it in ISO8601.
- makeFormSafe() : mixed
- formdata must be limited to scalars or arrays of scalar values, or a resource for a file upload. Here we iterate through all available data and identify how to handle each scenario.
- processFiles() : array<string|int, mixed>
- Handle file data.
- processModel() : array<string|int, mixed>
- We are able to handle nested ModelInterface. We do not simply call json_decode(json_encode()) because any given model may have binary data or other data that cannot be serialized to a JSON string.
- tryFopen() : mixed
Properties
$has_file
Tags whether payload passed to ::prepare() contains one or more SplFileObject or stream values.
public
bool
$has_file
= false
Methods
flatten()
Flattens a multi-level array of data and generates a single-level array compatible with formdata - a single-level array where the keys use bracket notation to signify nested data.
public
static flatten(array<string|int, mixed> $source[, string $start = '' ]) : array<string|int, mixed>
credit: https://github.com/FranBar1966/FlatPHP
Parameters
- $source : array<string|int, mixed>
- $start : string = ''
Return values
array<string|int, mixed>prepare()
Take value and turn it into an array suitable for inclusion in the http body (form parameter). If it's a string, pass through unchanged If it's a datetime object, format it in ISO8601.
public
prepare(array<string|int, array<string|int, mixed>|ArrayAccess|bool|DateTime|SplFileObject|string> $values) : array<string|int, mixed>
Parameters
- $values : array<string|int, array<string|int, mixed>|ArrayAccess|bool|DateTime|SplFileObject|string>
-
the value of the form parameter
Return values
array<string|int, mixed> —[key => value] of formdata
makeFormSafe()
formdata must be limited to scalars or arrays of scalar values, or a resource for a file upload. Here we iterate through all available data and identify how to handle each scenario.
protected
makeFormSafe(mixed $value) : mixed
Parameters
- $value : mixed
processFiles()
Handle file data.
protected
processFiles(array<string|int, mixed> $files) : array<string|int, mixed>
Parameters
- $files : array<string|int, mixed>
Return values
array<string|int, mixed>processModel()
We are able to handle nested ModelInterface. We do not simply call json_decode(json_encode()) because any given model may have binary data or other data that cannot be serialized to a JSON string.
protected
processModel(ModelInterface $model) : array<string|int, mixed>
Parameters
- $model : ModelInterface
Return values
array<string|int, mixed>tryFopen()
private
tryFopen(SplFileObject $file) : mixed
Parameters
- $file : SplFileObject