Neuron-PHP

Request
in package
implements IMapper

Maps HTTP Request data to DTOs with proper filtering

This mapper handles POST data, applying proper sanitization through the filter_input functions before mapping to DTO properties.

Table of Contents

Interfaces

IMapper

Methods

map()  : Dto
Map filtered POST data to DTO properties
mapFiltered()  : Dto
Map filtered POST array data to DTO

Methods

map()

Map filtered POST data to DTO properties

public map(Dto $dto[, array<string|int, mixed> $data = [] ]) : Dto

Iterates through all POST keys and maps them to corresponding DTO properties if they exist. Uses Post::filterScalar() for proper input sanitization.

Parameters
$dto : Dto

The DTO to populate

$data : array<string|int, mixed> = []

Optional data array. If empty, uses filtered POST data

Return values
Dto

The populated DTO

mapFiltered()

Map filtered POST array data to DTO

public mapFiltered(Dto $dto[, array<string|int, mixed> $fields = [] ]) : Dto

Alternative method that uses Post::filterArray() for batch filtering.

Parameters
$dto : Dto

The DTO to populate

$fields : array<string|int, mixed> = []

Field names to map (defaults to all POST fields)

Return values
Dto

The populated DTO


        
On this page

Search results