Skip to content

RoutingValue

Routing values are used internally and, optionally, by users in gen() calls and callbacks to have more control over encoding behavior and values in pre- and postfixes

class RoutingValue implements IRoutingValue, ResetInterface

ImplementsIRoutingValue, ResetInterface
Since1.0.0
SourceRouting/RoutingValue.php

public function __construct(mixed $value, bool $valueNeedsEncoding = true): mixed

Constructor.

Whether or not the value needs encoding.

ParameterTypeDescription
$valuemixedThe value.
$valueNeedsEncodingboolWhether or not the value needs encoding.

Returns mixed

MethodDescription
__sleep(): mixedPre-serialization callback.
__toString(): stringReturn the encoded value (without pre- or postfix) for BC.
__wakeup(): mixedPost-unserialization callback.
equals(mixed $other): boolCheck if this routing value is equal to the given parameter.
[`getPostfix(): stringnull`](#getpostfix)
getPostfixNeedsEncoding(): boolRetrieve whether or not the postfix needs to be encoded.
[`getPrefix(): stringnull`](#getprefix)
getPrefixNeedsEncoding(): boolRetrieve whether or not the prefix needs to be encoded.
getValue(): mixedRetrieve the value.
getValueNeedsEncoding(): boolRetrieve whether or not the value needs to be encoded.
hasPostfix(): boolCheck if a postfix is set.
hasPrefix(): boolCheck if a prefix is set.
initialize(Context $context, array<mixed> $parameters = []): mixedInitialize the routing value.
offsetExists(mixed $offset): boolArrayAccess method for isset().
offsetGet(mixed $offset): mixedArrayAccess method for getting a value.
offsetSet(mixed $offset, mixed $value): voidArrayAccess method for setting a value.
offsetUnset(mixed $offset): voidArrayAccess method for unset().
reset(): voidClears every piece of state the value carries.
setPostfix(string $value): $thisSet the postfix.
setPostfixNeedsEncoding(bool $needsEncoding): $thisSet whether or not the postfix needs to be encoded.
setPrefix(string $value): $thisSet the prefix.
setPrefixNeedsEncoding(bool $needsEncoding): $thisSet whether or not the prefix needs to be encoded.
setValue(mixed $value): $thisSet the value.
setValueNeedsEncoding(bool $needsEncoding): $thisSet whether or not the value needs to be encoded.

public function __sleep(): mixed

Pre-serialization callback.

Will set the name of the context instead of the instance, which will later be restored by __wakeup().

Returns mixed

public function __toString(): string

Return the encoded value (without pre- or postfix) for BC.

Returns string — The encoded value.

public function __wakeup(): mixed

Post-unserialization callback.

Will restore the context instance based on their names set by __sleep().

Returns mixed

public function equals(mixed $other): bool

Check if this routing value is equal to the given parameter.

The value to compare $this against.

ParameterTypeDescription
$othermixedThe value to compare $this against.

Returns bool — Whether the value matches $this.

public function getPostfix(): string|null

Retrieve the postfix.

Returns string``|``null — The postfix, or null if none is set.

public function getPostfixNeedsEncoding(): bool

Retrieve whether or not the postfix needs to be encoded.

Returns bool — True, if the postfix needs encoding, false otherwise.

public function getPrefix(): string|null

Retrieve the prefix.

Returns string``|``null — The prefix, or null if none is set.

public function getPrefixNeedsEncoding(): bool

Retrieve whether or not the prefix needs to be encoded.

Returns bool — True, if the prefix needs encoding, false otherwise.

public function getValue(): mixed

Retrieve the value.

Returns mixed — The value.

public function getValueNeedsEncoding(): bool

Retrieve whether or not the value needs to be encoded.

Returns bool — True, if the value needs encoding, false otherwise.

public function hasPostfix(): bool

Check if a postfix is set.

Returns bool — True, if a postfix is set, false otherwise.

public function hasPrefix(): bool

Check if a prefix is set.

Returns bool — True, if a prefix is set, false otherwise.

public function initialize(Context $context, array<mixed> $parameters = []): mixed

Initialize the routing value.

An array of initialization parameters.

ParameterTypeDescription
$contextContextThe Context.
$parametersarray``<``mixed``>An array of initialization parameters.

Returns mixed

public function offsetExists(mixed $offset): bool

ArrayAccess method for isset().

The offset.

ParameterTypeDescription
$offsetmixedThe offset.

Returns bool — Whether or not the given offset exists.

public function offsetGet(mixed $offset): mixed

ArrayAccess method for getting a value.

The offset.

ParameterTypeDescription
$offsetmixedThe offset.

Returns mixed — The value, nor null if the value does not exist.

public function offsetSet(mixed $offset, mixed $value): void

ArrayAccess method for setting a value.

The value.

ParameterTypeDescription
$offsetmixedThe offset.
$valuemixedThe value.

public function offsetUnset(mixed $offset): void

ArrayAccess method for unset().

The offset.

ParameterTypeDescription
$offsetmixedThe offset.

public function reset(): void

Clears every piece of state the value carries.

Drops the context and context name, the pre- and postfix along with their encoding flags, and unsets the constructor-promoted value and its encoding flag, so a container-managed instance holds nothing from the previous request. The instance is unusable until it is re-initialized: reading the value or casting to string before then hits an uninitialized property.

Only instance state is cleared. The pre/val/post offset map is a constant shared by every instance, so it stays put and ArrayAccess keeps resolving for the rest of the process.

public function setPostfix(string $value): $this

Set the postfix.

The postfix.

ParameterTypeDescription
$valuestringThe postfix.

Returns $this

public function setPostfixNeedsEncoding(bool $needsEncoding): $this

Set whether or not the postfix needs to be encoded.

True, if the postfix needs encoding, false otherwise.

ParameterTypeDescription
$needsEncodingboolTrue, if the postfix needs encoding, false otherwise.

Returns $this

public function setPrefix(string $value): $this

Set the prefix.

The prefix.

ParameterTypeDescription
$valuestringThe prefix.

Returns $this

public function setPrefixNeedsEncoding(bool $needsEncoding): $this

Set whether or not the prefix needs to be encoded.

True, if the prefix needs encoding, false otherwise.

ParameterTypeDescription
$needsEncodingboolTrue, if the prefix needs encoding, false otherwise.

Returns $this

public function setValue(mixed $value): $this

Set the value.

The value.

ParameterTypeDescription
$valuemixedThe value.

Returns $this

public function setValueNeedsEncoding(bool $needsEncoding): $this

Set whether or not the value needs to be encoded.

True, if the postfix needs encoding, false otherwise.

ParameterTypeDescription
$needsEncodingboolTrue, if the postfix needs encoding, false otherwise.

Returns $this