Neuron-PHP

Dynamic
in package
implements IMapper

Table of Contents

Interfaces

IMapper

Properties

$aliases  : array<string|int, mixed>
$fields  : array<string|int, mixed>
$name  : string
$properties  : array<string|int, mixed>
$strictErrors  : bool
$strictMapping  : bool

Methods

__construct()  : mixed
createDataMap()  : void
flattenFields()  : void
Recursively turns a nested dictionary into a single dimensional dictionary with flat keys.
flattenProperties()  : void
Recursively turns a dto into a single dimensional dictionary with flat keys.
getAlias()  : string|null
Gets the property key for a given alias.
getArrayPath()  : array<string|int, mixed>|null
Returns an array that represents the individual stages of single and multidimensional arrays.
getFields()  : array<string|int, mixed>
getName()  : string
getProperties()  : array<string|int, mixed>
isStrictErrors()  : bool
isStrictMapping()  : bool
StrictMapping generates an error for missing mapping.
map()  : Dto
Assign data to a dto based on specific field mapping.
setAlias()  : $this
Sets the mapping alias for a property key.
setName()  : $this
setStrictErrors()  : $this
StrictErrors generates a type error immediately instead of returning the errors in batch.
setStrictMapping()  : $this
buildArrayPart()  : array<string|int, mixed>
Build a the data that represents a single array step within an assignment.
flattenArray()  : void
getPropertyByAlias()  : Property|null
Gets a dto parameter based on its assigned alias.
getPropertyByKey()  : Property|null
Gets a dto by its assigned key
isArray()  : bool
Returns true if the Key references an array.
mapArray()  : void
Map single and multidimensional arrays.
mapScalar()  : void
Map a non-compound variable.
mapDto()  : void
Internal mapping method.

Properties

$aliases

private array<string|int, mixed> $aliases = []

$fields

private array<string|int, mixed> $fields

$properties

private array<string|int, mixed> $properties

$strictErrors

private bool $strictErrors = false

$strictMapping

private bool $strictMapping = false

Methods

__construct()

public __construct() : mixed

createDataMap()

public createDataMap(Dto $dto, array<string|int, mixed> $data) : void
Parameters
$dto : Dto
$data : array<string|int, mixed>

flattenFields()

Recursively turns a nested dictionary into a single dimensional dictionary with flat keys.

public flattenFields(array<string|int, mixed> $array[, string|null $currentKey = null ]) : void

The result is a one level dictionary where each field is keyed such that level1.level2.level3.parameter = value.

Parameters
$array : array<string|int, mixed>
$currentKey : string|null = null

flattenProperties()

Recursively turns a dto into a single dimensional dictionary with flat keys.

public flattenProperties(Dto $dto[, string|null $masterKey = null ]) : void

The result is a one level dictionary where each field is keyed such that level1.level2.level3.parameter = parameter.

Parameters
$dto : Dto
$masterKey : string|null = null

getAlias()

Gets the property key for a given alias.

public getAlias(string $aliasName) : string|null
Parameters
$aliasName : string
Return values
string|null

getArrayPath()

Returns an array that represents the individual stages of single and multidimensional arrays.

public getArrayPath(string $key) : array<string|int, mixed>|null

ArrayKey points to the array. Element is the index of the array element. ItemKey points to the parameter being set in the array element. Name is the de-aliased name of the parameter to be set.

Parameters
$key : string
Tags
throws
MapNotFound
Return values
array<string|int, mixed>|null

getFields()

public getFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getName()

public getName() : string
Return values
string

getProperties()

public getProperties() : array<string|int, mixed>
Return values
array<string|int, mixed>

isStrictErrors()

public isStrictErrors() : bool
Return values
bool

isStrictMapping()

StrictMapping generates an error for missing mapping.

public isStrictMapping() : bool
Return values
bool

map()

Assign data to a dto based on specific field mapping.

public map(Dto $dto, array<string|int, mixed> $data) : Dto
Parameters
$dto : Dto
$data : array<string|int, mixed>
Tags
throws
MapNotFound
throws
Validation
throws
Validation
Return values
Dto

setAlias()

Sets the mapping alias for a property key.

public setAlias(string $propertyName, string $aliasName) : $this
Parameters
$propertyName : string
$aliasName : string
Return values
$this

setName()

public setName(string $name) : $this
Parameters
$name : string
Return values
$this

setStrictErrors()

StrictErrors generates a type error immediately instead of returning the errors in batch.

public setStrictErrors(bool $strict) : $this
Parameters
$strict : bool
Return values
$this

setStrictMapping()

public setStrictMapping(bool $strictMapping) : $this
Parameters
$strictMapping : bool
Return values
$this

buildArrayPart()

Build a the data that represents a single array step within an assignment.

protected buildArrayPart(string $arrayKey, int $element, string $name) : array<string|int, mixed>
Parameters
$arrayKey : string
$element : int
$name : string
Tags
throws
MapNotFound
Return values
array<string|int, mixed>

flattenArray()

protected flattenArray(Property $property, string $key, string $masterKey) : void
Parameters
$property : Property
$key : string
$masterKey : string

getPropertyByAlias()

Gets a dto parameter based on its assigned alias.

protected getPropertyByAlias(string $key) : Property|null
Parameters
$key : string
Return values
Property|null

getPropertyByKey()

Gets a dto by its assigned key

protected getPropertyByKey(string $key) : Property|null
Parameters
$key : string
Return values
Property|null

isArray()

Returns true if the Key references an array.

protected isArray(string $key) : bool
Parameters
$key : string
Return values
bool

mapArray()

Map single and multidimensional arrays.

protected mapArray(array<string|int, mixed> $arrayData, mixed $value) : void

This method walks through an array that contains parts that represent an object and array offset within each part of the mapped field key as, each field key can reference different offsets from multiple nested arrays. A path must be walked through to get to the final value to be set and the ArrayData is the map.

Parameters
$arrayData : array<string|int, mixed>
$value : mixed
Tags
throws
Validation

mapScalar()

Map a non-compound variable.

protected mapScalar(int|string $key, mixed $value) : void
Parameters
$key : int|string
$value : mixed
Tags
throws
NotFound

mapDto()

Internal mapping method.

private mapDto(Dto $dto, array<string|int, mixed> $data) : void
Parameters
$dto : Dto
$data : array<string|int, mixed>
Tags
throws
Validation

| Exceptions\MapNotFound|\Neuron\Dto\Validation


        
On this page

Search results