Overview

Namespaces

  • Charcoal
    • Config

Classes

  • AbstractConfig
  • AbstractEntity
  • GenericConfig

Interfaces

  • ConfigInterface
  • ConfigurableInterface
  • DelegatesAwareInterface
  • EntityInterface
  • FileAwareInterface
  • SeparatorAwareInterface

Traits

  • ConfigurableTrait
  • DelegatesAwareTrait
  • FileAwareTrait
  • SeparatorAwareTrait
  • Overview
  • Namespace
  • Class

Class AbstractConfig

Default configuration container / registry.

Notes on Charcoal\Config\SeparatorAwareTrait:

  • Provides the ability for a store to fetch data that is nested in a tree-like structure, often referred to as "dot" notation.

Notes on Charcoal\Config\DelegatesAwareTrait:

  • Provides the ability for a store to fetch data in another store.
  • Provides this store with a way to register one or more delegate stores.
Charcoal\Config\AbstractEntity implements Charcoal\Config\EntityInterface
Extended by Charcoal\Config\AbstractConfig implements Charcoal\Config\ConfigInterface, Psr\Container\ContainerInterface, IteratorAggregate uses Charcoal\Config\DelegatesAwareTrait, Charcoal\Config\FileAwareTrait, Charcoal\Config\SeparatorAwareTrait

Direct known subclasses

Charcoal\Config\GenericConfig
Abstract
Namespace: Charcoal\Config
Located at Charcoal/Config/AbstractConfig.php
Methods summary
final public
# __construct( mixed $data = null, array $delegates = null )

Create the configuration.

Create the configuration.

Parameters

$data

Initial data. Either a filepath, an associative array, or an Traversable iterable object.

$delegates
An array of delegates (config) to set.

Throws

InvalidArgumentException
If $data is invalid.
public array
# defaults( )

Gets all default data from this store.

Gets all default data from this store.

Pre-populates new stores.

May be reimplemented in inherited classes if any default values should be defined.

Returns

array
Key-value array of data

Implementation of

Charcoal\Config\ConfigInterface::defaults()
public Charcoal\Config\AbstractConfig
# merge( array|Traversable $data )

Adds new data, replacing / merging existing data with the same key.

Adds new data, replacing / merging existing data with the same key.

Parameters

$data

Key-value dataset to merge. Either an associative array or an Traversable iterable object (such as Charcoal\Config\ConfigInterface).

Returns

Charcoal\Config\AbstractConfig

Uses

Charcoal\Config\AbstractConfig::offsetReplace()

Implementation of

Charcoal\Config\ConfigInterface::merge()
public ArrayIterator
# getIterator( )

Create a new iterator from the configuration instance.

Create a new iterator from the configuration instance.

Returns

ArrayIterator

See

IteratorAggregate

Implementation of

IteratorAggregate::getIterator()
public boolean
# offsetExists( string $key )

Determines if this store contains the specified key and if its value is not NULL.

Determines if this store contains the specified key and if its value is not NULL.

Routine: - If the data key is nested, the data-tree is traversed until the endpoint is found, if any; - If the data key does NOT exist on the store, a lookup is performed on each delegate store until a key is found, if any.

Parameters

$key
The data key to check.

Returns

boolean
TRUE if $key exists and has a value other than NULL, FALSE otherwise.

Throws

InvalidArgumentException
If the $key is not a string or is a numeric value.

See

\ArrayAccess

Uses

Charcoal\Config\SeparatorAwareTrait::hasWithSeparator()
Charcoal\Config\DelegatesAwareTrait::hasInDelegates()

Overrides

Charcoal\Config\AbstractEntity::offsetExists()
public mixed
# offsetGet( string $key )

Returns the value from the specified key on this entity.

Returns the value from the specified key on this entity.

Routine: - If the data key is nested, the data-tree is traversed until the endpoint to return its value, if any; - If the data key does NOT exist on the store, a lookup is performed on each delegate store until a value is found, if any.

Parameters

$key
The data key to retrieve.

Returns

mixed
Value of the requested $key on success, NULL if the $key is not set.

Throws

InvalidArgumentException
If the $key is not a string or is a numeric value.

See

\ArrayAccess

Uses

Charcoal\Config\SeparatorAwareTrait::getWithSeparator()
Charcoal\Config\DelegatesAwareTrait::getInDelegates()

Overrides

Charcoal\Config\AbstractEntity::offsetGet()
public
# offsetSet( string $key, mixed $value )

Assigns the value to the specified key on this entity.

Assigns the value to the specified key on this entity.

Routine: - If the data key is nested, the data-tree is traversed until the endpoint to assign its value;

Parameters

$key
The data key to assign $value to.
$value
The data value to assign to $key.

Throws

InvalidArgumentException
If the $key is not a string or is a numeric value.

See

\ArrayAccess

Uses

Charcoal\Config\SeparatorAwareTrait::setWithSeparator()

Used by

Charcoal\Config\AbstractConfig::offsetReplace()

Overrides

Charcoal\Config\AbstractEntity::offsetSet()
public
# offsetReplace( string $key, mixed $value )

Replaces the value from the specified key.

Replaces the value from the specified key.

Routine: - When the value in the Config and the new value are both arrays, the method will replace their respective value recursively. - Then or otherwise, the new value is assigned to the Config.

Parameters

$key
The data key to assign or merge $value to.
$value
The data value to assign to or merge with $key.

Throws

InvalidArgumentException
If the $key is not a string or is a numeric value.

Uses

Charcoal\Config\AbstractConfig::offsetSet()
array_replace_recursive()

Used by

Charcoal\Config\AbstractConfig::merge()
public Charcoal\Config\AbstractConfig
# addFile( string $path )

Adds a configuration file to the configset.

Adds a configuration file to the configset.

Natively supported file formats: INI, JSON, PHP.

Parameters

$path
The file to load and add.

Returns

Charcoal\Config\AbstractConfig

Uses

Charcoal\Config\FileAwareTrait::loadFile()

Implementation of

Charcoal\Config\ConfigInterface::addFile()
Methods inherited from Charcoal\Config\AbstractEntity
camelize(), data(), get(), has(), jsonSerialize(), keys(), offsetUnset(), serialize(), set(), setData(), unserialize()
Methods inherited from Charcoal\Config\SeparatorAwareInterface
setSeparator()
Methods inherited from Charcoal\Config\FileAwareInterface
loadFile()
Methods inherited from Charcoal\Config\DelegatesAwareInterface
addDelegate(), prependDelegate(), setDelegates()
Methods used from Charcoal\Config\DelegatesAwareTrait
addDelegate(), getInDelegates(), hasInDelegates(), prependDelegate(), setDelegates()
Methods used from Charcoal\Config\FileAwareTrait
loadFile()
Methods used from Charcoal\Config\SeparatorAwareTrait
getWithSeparator(), hasWithSeparator(), separator(), setSeparator(), setWithSeparator()
Constants summary
string DEFAULT_SEPARATOR
# '.'
Properties inherited from Charcoal\Config\AbstractEntity
$keys
Properties used from Charcoal\Config\SeparatorAwareTrait
$separator
API documentation generated by ApiGen