Time2Configure

TreeConfiguration extends BaseConfiguration

A configuration with a tree-shaped structure, that is a sequence of (K => V) where V can recursively contains entries.

An entry access is done using a single string key (eg. $config[$key]) representing a path (ie. a branch) in the tree. For now only string keys are allowed, a (near) future extension will be to allow any type of key.

Each part of the path is delimited by an internal delimiter character. Each node of the tree can be associated with a value.

Tags
template

K

template

V

extends

BaseConfiguration<K,V,mixed>

author

Olivier Rodriguez (zuri)

Table of Contents

Methods

clear()  : void
Drops all items from the configuration.
copy()  : static
Makes a copy of the configuration.
copyBranches()  : static
Gets some branches of the configuration.
getInterpolator()  : Interpolator<V, I>
Gets the interpolator used.
getIterator()  : Iterator<K, V>
Gets an iterator over the entries in the selected reading mode.
getOptional()  : Optional<string|int, V>
Retrieves the value of an entry in an Optional.
isPresent()  : bool
Whether an offset is present with a value (the value may be null).
nodeIsPresent()  : bool
Whether a node is present in the tree.
offsetExists()  : bool
Whether an offset exists.
offsetGet()  : V
Retrieves the value of an entry.
offsetSet()  : void
Assigns a value to the specified offset.
offsetUnset()  : void
Unsets an offset
removeNode()  : void
Removes a node from the configuration.
subTreeCopy()  : static
Gets a sub-tree copy.
subTreeView()  : static
Returns a view on a sub-tree.

Methods

copy()

Makes a copy of the configuration.

public copy([Interpolator $interpolator = null ]) : static
Parameters
$interpolator : Interpolator = null

The interpolator to use for the copy.

  • (null) If not set then the copy contains the interpolated value of the configuration tree and will never do interpolation.
  • (isset) If set then the copy uses this interpolator on the raw base value to create a new interpolated configuration. Note that the interpolator may be the same as $config, in that case it means that the same interpolation is conserved.
Return values
static

The copy.

copyBranches()

Gets some branches of the configuration.

public copyBranches(K $path, K ...$paths) : static
Parameters
$path : K

A first path to a sub-tree.

$paths : K

More paths to more sub-trees.

Return values
static

A new instance of the configuration containing the selected nodes branches and their sub-tree.

getIterator()

Gets an iterator over the entries in the selected reading mode.

public getIterator([ReadingMode $mode = ReadingMode::Normal ]) : Iterator<K, V>
Parameters
$mode : ReadingMode = ReadingMode::Normal

The mode with which to retrieves the entry value.

Tags
see
ReadingMode
Return values
Iterator<K, V>

getOptional()

Retrieves the value of an entry in an Optional.

public getOptional(K|null $offset[, ReadingMode $mode = ReadingMode::Normal ]) : Optional<string|int, V>
Parameters
$offset : K|null

The offset to retrieve.

$mode : ReadingMode = ReadingMode::Normal

The mode with which to retrieves the entry value.

Tags
link

Optional

Return values
Optional<string|int, V>

An optional of the value to retrieve, or an empty optional if the offset is absent.

isPresent()

Whether an offset is present with a value (the value may be null).

public isPresent(K|null $offset) : bool
Parameters
$offset : K|null

An offset to check for.

Return values
bool

Returns true on success or false on failure.

nodeIsPresent()

Whether a node is present in the tree.

public nodeIsPresent(K $path) : bool
Parameters
$path : K

A path to check for.

Return values
bool

Returns true on success or false on failure.

offsetExists()

Whether an offset exists.

public offsetExists(K|null $offset) : bool
Parameters
$offset : K|null

An offset to check for.

Return values
bool

Returns true on success or false on failure.

offsetGet()

Retrieves the value of an entry.

public offsetGet(K|null $offset[, ReadingMode $mode = ReadingMode::Normal ]) : V
Parameters
$offset : K|null

The key of the entry to retrieve.

$mode : ReadingMode = ReadingMode::Normal

The mode with which to retrieve the entry value.

Tags
see
ArrayAccess::offsetGet()
Return values
V

The value of the offset, or null if absent.

offsetSet()

Assigns a value to the specified offset.

public offsetSet(K|null $offset, V $value) : void
Parameters
$offset : K|null

The offset to assign the value to.

$value : V

The value to set.

offsetUnset()

Unsets an offset

public offsetUnset(K|null $offset) : void
Parameters
$offset : K|null

The offset to unset.

removeNode()

Removes a node from the configuration.

public removeNode(K $path) : void
Parameters
$path : K

A path to a node.

subTreeCopy()

Gets a sub-tree copy.

public subTreeCopy(K $path) : static
Parameters
$path : K

A path to the sub-tree.

Return values
static

A new instance of the configuration containing the sub-tree.

subTreeView()

Returns a view on a sub-tree.

public subTreeView(K $path) : static

Because of the referencing of a sub-tree, updating one configuration's sub-tree will updates the other.

Parameters
$path : K

A path to the sub-tree.

Return values
static

A configuration that reference the content of the sub-tree of the initial configuration.


        
On this page

Search results