class TransformationContextFactory implements Transient

Traits

Properties

protected bool $transformValues
protected bool $mapPropertyNames
protected bool $constructable
protected WrapExecutionType $wrapExecutionType
protected Transformer>|Transformer> $transformers
protected int|null $maxDepth
protected bool $throwWhenMaxDepthReached
protected int|null $configuredMaxDepth
protected PartialsDefinition $partialDefinitions

Methods

getPartialsDefinition()

Get the partial definition store.

include(string ...$includes)

Include properties for the next transformation.

includePermanently(string ...$includes)

Include properties for every transformation.

exclude(string ...$excludes)

Exclude lazy properties for the next transformation.

excludePermanently(string ...$excludes)

Exclude lazy properties for every transformation.

only(string ...$only)

Keep only properties for the next transformation.

onlyPermanently(string ...$only)

Keep only properties for every transformation.

except(string ...$except)

Exclude properties for the next transformation.

exceptPermanently(string ...$except)

Exclude properties for every transformation.

includeWhen(string $include, bool|Closure $condition, bool $permanent = false)

Include a property when the condition passes.

excludeWhen(string $exclude, bool|Closure $condition, bool $permanent = false)

Exclude a lazy property when the condition passes.

onlyWhen(string $only, bool|Closure $condition, bool $permanent = false)

Keep only a property when the condition passes.

exceptWhen(string $except, bool|Closure $condition, bool $permanent = false)

Exclude a property when the condition passes.

__construct(DataConfig $config)

Create a transformation context factory.

create()

Create a fresh transformation context factory.

forPersistence()

Create a fresh constructable persistence context factory.

persistenceContext(int|null $maxDepth)

Create the immutable constructable persistence context.

get(object $data)

Build the context for one root transformation.

withValueTransformation(bool $transformValues = true)

Enable or disable value transformation.

withoutValueTransformation(bool $withoutValueTransformation = true)

Disable or enable value transformation.

withPropertyNameMapping(bool $mapPropertyNames = true)

Enable or disable output property-name mapping.

withoutPropertyNameMapping(bool $withoutPropertyNameMapping = true)

Disable or enable output property-name mapping.

withWrapExecutionType(WrapExecutionType $wrapExecutionType)

Set wrapping behavior for the transformation.

withoutWrapping()

Disable wrapping for the transformation.

withWrapping()

Enable wrapping for the transformation.

withTransformer(string $transformable, Transformer|string $transformer)

Add a transformer for one declared or runtime type.

maxDepth(int|null $maxDepth, bool $throw = true)

Set the maximum nested transformation depth.

Details

at line 253
protected PartialsDefinition getPartialsDefinition()

Get the partial definition store.

Return Value

PartialsDefinition

ForwardsToPartialsDefinition include(string ...$includes)

Include properties for the next transformation.

Parameters

string ...$includes

Return Value

ForwardsToPartialsDefinition

ForwardsToPartialsDefinition includePermanently(string ...$includes)

Include properties for every transformation.

Parameters

string ...$includes

Return Value

ForwardsToPartialsDefinition

ForwardsToPartialsDefinition exclude(string ...$excludes)

Exclude lazy properties for the next transformation.

Parameters

string ...$excludes

Return Value

ForwardsToPartialsDefinition

ForwardsToPartialsDefinition excludePermanently(string ...$excludes)

Exclude lazy properties for every transformation.

Parameters

string ...$excludes

Return Value

ForwardsToPartialsDefinition

ForwardsToPartialsDefinition only(string ...$only)

Keep only properties for the next transformation.

Parameters

string ...$only

Return Value

ForwardsToPartialsDefinition

ForwardsToPartialsDefinition onlyPermanently(string ...$only)

Keep only properties for every transformation.

Parameters

string ...$only

Return Value

ForwardsToPartialsDefinition

ForwardsToPartialsDefinition except(string ...$except)

Exclude properties for the next transformation.

Parameters

string ...$except

Return Value

ForwardsToPartialsDefinition

ForwardsToPartialsDefinition exceptPermanently(string ...$except)

Exclude properties for every transformation.

Parameters

string ...$except

Return Value

ForwardsToPartialsDefinition

ForwardsToPartialsDefinition includeWhen(string $include, bool|Closure $condition, bool $permanent = false)

Include a property when the condition passes.

Parameters

string $include
bool|Closure $condition
bool $permanent

Return Value

ForwardsToPartialsDefinition

ForwardsToPartialsDefinition excludeWhen(string $exclude, bool|Closure $condition, bool $permanent = false)

Exclude a lazy property when the condition passes.

Parameters

string $exclude
bool|Closure $condition
bool $permanent

Return Value

ForwardsToPartialsDefinition

ForwardsToPartialsDefinition onlyWhen(string $only, bool|Closure $condition, bool $permanent = false)

Keep only a property when the condition passes.

Parameters

string $only
bool|Closure $condition
bool $permanent

Return Value

ForwardsToPartialsDefinition

ForwardsToPartialsDefinition exceptWhen(string $except, bool|Closure $condition, bool $permanent = false)

Exclude a property when the condition passes.

Parameters

string $except
bool|Closure $condition
bool $permanent

Return Value

ForwardsToPartialsDefinition

at line 43
__construct(DataConfig $config)

Create a transformation context factory.

Parameters

DataConfig $config

at line 54
static TransformationContextFactory create()

Create a fresh transformation context factory.

at line 63
static TransformationContextFactory forPersistence()

Create a fresh constructable persistence context factory.

at line 74
static TransformationContext persistenceContext(int|null $maxDepth)

Create the immutable constructable persistence context.

Parameters

int|null $maxDepth

Return Value

TransformationContext

at line 89
TransformationContext get(object $data)

Build the context for one root transformation.

Parameters

object $data

Return Value

TransformationContext

at line 141
TransformationContextFactory withValueTransformation(bool $transformValues = true)

Enable or disable value transformation.

Parameters

bool $transformValues

Return Value

TransformationContextFactory

at line 151
TransformationContextFactory withoutValueTransformation(bool $withoutValueTransformation = true)

Disable or enable value transformation.

Parameters

bool $withoutValueTransformation

Return Value

TransformationContextFactory

at line 161
TransformationContextFactory withPropertyNameMapping(bool $mapPropertyNames = true)

Enable or disable output property-name mapping.

Parameters

bool $mapPropertyNames

Return Value

TransformationContextFactory

at line 171
TransformationContextFactory withoutPropertyNameMapping(bool $withoutPropertyNameMapping = true)

Disable or enable output property-name mapping.

Parameters

bool $withoutPropertyNameMapping

Return Value

TransformationContextFactory

at line 181
TransformationContextFactory withWrapExecutionType(WrapExecutionType $wrapExecutionType)

Set wrapping behavior for the transformation.

Parameters

WrapExecutionType $wrapExecutionType

Return Value

TransformationContextFactory

at line 191
TransformationContextFactory withoutWrapping()

Disable wrapping for the transformation.

at line 201
TransformationContextFactory withWrapping()

Enable wrapping for the transformation.

at line 213
TransformationContextFactory withTransformer(string $transformable, Transformer|string $transformer)

Add a transformer for one declared or runtime type.

Parameters

string $transformable
Transformer|string $transformer

Return Value

TransformationContextFactory

at line 225
TransformationContextFactory maxDepth(int|null $maxDepth, bool $throw = true)

Set the maximum nested transformation depth.

Parameters

int|null $maxDepth
bool $throw

Whether reaching the depth throws instead of returning an empty array

Return Value

TransformationContextFactory