SlotCodec
in
Defines how slots are serialized, deserialized, and pattern-matched.
Tags
Table of Contents
Methods
- __construct() : mixed
- alternative() : non-empty-string
- Return the token used to express value alternatives inside one dimension.
- deserialize() : array<non-empty-string, non-empty-string|null>|null
- Parse a serialized slot key or pattern into its associative dimension form.
- dimensionSeparator() : non-empty-string
- Return the separator used between serialized dimension values.
- initialDimensionValueValidation() : void
- Validate that the slot-space dimension values are compatible with the codec syntax.
- isWildcard() : bool
- Return true when the given value should be treated as a match-all wildcard.
- matchDimensionValues() : array<int, non-empty-string>
- For one dimension, expand a value pattern to all matching concrete values.
- nilKey() : non-empty-string
- Return the reserved key for the special nil source/sink slot.
- serialize() : non-empty-string
- Serialize a slot or slot-pattern array to the codec's canonical string form.
- validateDimensionValue() : void
- Validate that the given value is valid for the given dimension, and throw an exception if not.
- validateDimensionValues() : void
- Validate that the given values are valid for their respective dimensions, and throw an exception if not. This is used to validate patterns before trying to match them.
- wildcard() : non-empty-string
- Return the canonical wildcard token used by this codec.
Methods
__construct()
public
__construct(SlotSpace $space) : mixed
Parameters
- $space : SlotSpace
Tags
alternative()
Return the token used to express value alternatives inside one dimension.
public
alternative() : non-empty-string
Return values
non-empty-stringdeserialize()
Parse a serialized slot key or pattern into its associative dimension form.
public
deserialize(string|null $key) : array<non-empty-string, non-empty-string|null>|null
Parameters
- $key : string|null
Tags
Return values
array<non-empty-string, non-empty-string|null>|nulldimensionSeparator()
Return the separator used between serialized dimension values.
public
dimensionSeparator() : non-empty-string
Return values
non-empty-stringinitialDimensionValueValidation()
Validate that the slot-space dimension values are compatible with the codec syntax.
public
initialDimensionValueValidation(array<non-empty-string, array<int, non-empty-string>> $dimensions) : void
Parameters
- $dimensions : array<non-empty-string, array<int, non-empty-string>>
isWildcard()
Return true when the given value should be treated as a match-all wildcard.
public
isWildcard(string|null $value) : bool
Parameters
- $value : string|null
Return values
boolmatchDimensionValues()
For one dimension, expand a value pattern to all matching concrete values.
public
matchDimensionValues(non-empty-string $dimension, string|null $pattern) : array<int, non-empty-string>
The pattern can be:
- a specific value, which matches only that value
- a WILDCARD, which matches all values for that dimension
- a string containing one or more WILDCARDs, which matches any value that fits the pattern
- null or empty string, which are treated the same as the WILDCARD and match all values for that dimension
- a series of ALTERNATIVE string patterns, e.g. 'a|bd|d'
Parameters
- $dimension : non-empty-string
- $pattern : string|null
Return values
array<int, non-empty-string>nilKey()
Return the reserved key for the special nil source/sink slot.
public
nilKey() : non-empty-string
Return values
non-empty-string —a special key representing out-of-space source/sink slot
serialize()
Serialize a slot or slot-pattern array to the codec's canonical string form.
public
serialize(array<int, string|null>|array<non-empty-string, string|null>|null $values) : non-empty-string
List inputs are interpreted positionally in dimension order. Associative inputs are interpreted by dimension name, with missing values treated as wildcards.
Parameters
- $values : array<int, string|null>|array<non-empty-string, string|null>|null
Tags
Return values
non-empty-stringvalidateDimensionValue()
Validate that the given value is valid for the given dimension, and throw an exception if not.
public
validateDimensionValue(non-empty-string $dimension, string|null $value, bool $allowWildcards) : void
Parameters
- $dimension : non-empty-string
- $value : string|null
- $allowWildcards : bool
Tags
validateDimensionValues()
Validate that the given values are valid for their respective dimensions, and throw an exception if not. This is used to validate patterns before trying to match them.
public
validateDimensionValues(array<non-empty-string, array<string|int, string|null>|string|null> $values[, bool $allowWildcards = false ][, bool $allowValueArrays = false ]) : void
Parameters
- $values : array<non-empty-string, array<string|int, string|null>|string|null>
- $allowWildcards : bool = false
- $allowValueArrays : bool = false
Tags
wildcard()
Return the canonical wildcard token used by this codec.
public
wildcard() : non-empty-string