Documentation

IFormTransformer

Transforms the data submitted with a POST request from its PHP representation (parsedBody) to its representation in the app (formData).

Tags
todo

Add tests, with fuzzing.

phpstan-type

parsedpayload array

Table of Contents

Methods

transformSubmittedData()  : mixed
Extract the submitted value for the given field and convert it to the app data format.

Methods

transformSubmittedData()

Extract the submitted value for the given field and convert it to the app data format.

public transformSubmittedData(parsedpayload $parsedPayload, array<string, array<string, UploadedFileInterface>|UploadedFileInterface$uploadedFiles) : mixed

It is not always possible to decide whether a value evaluating to null or false was submitted or if no value was submitted because of a malformed or non-valid request for instance. For instance unchecked checkboxes submit the same value (actually, no submitted value at all, not even null), than if the field did not exist in the HTML form at all. A string left blank will evaluate to an empty string and not to null.

Parameters
$parsedPayload : parsedpayload
$uploadedFiles : array<string, array<string, UploadedFileInterface>|UploadedFileInterface>
Tags
throws
MissingInputException

If no value was submitted for the field.

Return values
mixed

The submitted value converted to the app data format, or null if the user submitted a value evaluating to null.

On this page

Search results