BaseConfiguration
extends
ArrayAccess, IteratorAggregate, Countable
in
A sequence of (K => V) entries with automatic interpolation features.
This is the base interface that must implement all configuration instances. The library provides (for now) only Configuration implementations that may be instanciated with the Configurations factory methods.
Note that this interface does not describe the format and the semantic of the key part, it may be as simple of php array keys, or be more complex like a hierarchical structure "a.b.c".
Tags
Table of Contents
Methods
- clear() : void
- Drops all items from the configuration.
- copy() : static
- Makes a copy 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).
- 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
Methods
clear()
Drops all items from the configuration.
public
clear() : void
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.
getInterpolator()
Gets the interpolator used.
public
getInterpolator() : Interpolator<V, I>
Return values
Interpolator<V, I> —The configuration interpolator.
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
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
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.
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
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.