Erebot  latest
A modular IRC bot for PHP 7.0+
Erebot\Config\Proxy Class Reference

A configuration proxy which cascades settings. More...

+ Inheritance diagram for Erebot\Config\Proxy:

Public Member Functions

 __clone ()
 
 __destruct ()
 
 getMainCfg ()
 
 getModule ($moduleName)
 
 getModules ($recursive)
 
 getTranslator ($component)
 
 parseBool ($module, $param, $default=null)
 
 parseInt ($module, $param, $default=null)
 
 parseReal ($module, $param, $default=null)
 
 parseString ($module, $param, $default=null)
 

Static Public Member Functions

static parseBoolHelper ($value)
 
static parseIntHelper ($value)
 
static parseRealHelper ($value)
 

Protected Member Functions

 __construct (\Erebot\Interfaces\Config\Proxy $proxified,\SimpleXMLElement $xml)
 
 parseSomething ($module, $param, $default, callable $parser, $origin, callable $checker)
 

Static Protected Member Functions

static getBaseDir ($component)
 

Protected Attributes

 $locale
 The current locale.
 
 $modules
 Array of modules loaded at this particular configuration level.
 
 $proxified
 Reference to a proxified object.
 

Detailed Description

A configuration proxy which cascades settings.

This class is used to build a hierarchy of configurations. Each level in this hierarchy may override settings applied at upper levels. If no override has been made on some setting, that setting retains the value it had on the preceding level. This allows settings to be cascaded in the hierarchy of configuration levels.

The root of the hierarchy acts as a proxy for itself and always implements Erebot::Interfaces::Config::Main.

Definition at line 37 of file Proxy.php.

Constructor & Destructor Documentation

Erebot\Config\Proxy::__construct ( \Erebot\Interfaces\Config\Proxy  $proxified,
\SimpleXMLElement  $xml 
)
protected

Creates a new Erebot::Proxy::Config object.

Parameters
Erebot::Interfaces::Config::Proxy$proxifiedA configuration object which should be proxied through this instance. This allows settings to be cascaded.
SimpleXMLElement$xmlAn XML node which should be used as the basis for configuration.

Definition at line 58 of file Proxy.php.

References Erebot\Config\Proxy\$proxified.

Erebot\Config\Proxy::__destruct ( )

Destructor. Takes care of breaking possible circular references.

Definition at line 86 of file Proxy.php.

Member Function Documentation

Erebot\Config\Proxy::__clone ( )

Copy constructor.

Definition at line 97 of file Proxy.php.

Erebot\Config\Proxy::getMainCfg ( )

Definition at line 132 of file Proxy.php.

Erebot\Config\Proxy::getModule (   $moduleName)

Definition at line 170 of file Proxy.php.

Erebot\Config\Proxy::getModules (   $recursive)

Definition at line 141 of file Proxy.php.

Erebot\Config\Proxy::getTranslator (   $component)

Definition at line 116 of file Proxy.php.

Erebot\Config\Proxy::parseBool (   $module,
  $param,
  $default = null 
)

Definition at line 352 of file Proxy.php.

References Erebot\Config\Proxy\parseSomething().

Referenced by Erebot\Config\Main\load().

static Erebot\Config\Proxy::parseBoolHelper (   $value)
static

Parses a text and tries to extract a boolean value.

Parameters
string$valueThe text from which a boolean should be extracted.
Return values
boolIf a boolean could be extracted from the $value provided, it is returned as the corresponding PHP boolean value (either true or false).
nullNo boolean could be extracted.
Note
Currently, the following texts are recognized as true: "true", "1", "on" & "yes", while the values "false", "0", "off" & "no" are recognized as false. The comparison is case-insensitive (ie. "true" == "TrUe").

Definition at line 203 of file Proxy.php.

Erebot\Config\Proxy::parseInt (   $module,
  $param,
  $default = null 
)

Definition at line 378 of file Proxy.php.

References Erebot\Config\Proxy\parseSomething().

static Erebot\Config\Proxy::parseIntHelper (   $value)
static

Parses a text and tries to extract an integer value.

Parameters
string$valueThe text from which an integer should be extracted.
Return values
intIf an integer could be extracted from the $value provided, it is returned as the corresponding PHP (signed) integer value.
nullIf no integer could be extracted.

Definition at line 228 of file Proxy.php.

Erebot\Config\Proxy::parseReal (   $module,
  $param,
  $default = null 
)

Definition at line 391 of file Proxy.php.

References Erebot\Config\Proxy\parseSomething().

static Erebot\Config\Proxy::parseRealHelper (   $value)
static

Parses a text and tries to extract a real.

Parameters
string$valueThe text from which a real should be extracted.
Return values
floatIf a real could be extracted from the $value provided, it is returned as the corresponding PHP float value.
nullIf no real could be extracted.

Definition at line 262 of file Proxy.php.

Erebot\Config\Proxy::parseSomething (   $module,
  $param,
  $default,
callable  $parser,
  $origin,
callable  $checker 
)
protected

Returns the typed value for a module's parameter.

Parameters
string$moduleThe name of the module.
string$paramThe name of the parameter to fetch from the module's settings.
mixed$defaultDefault value if no value has been defined in the module's settings, or null if there is no default value.
callable$parserObject that will be used to parse the parameter. It will receive the value of that parameter as a string and should convert it to the proper type.
string$originName of the method the request to parse the parameter originated from.
callable$checkerObject that will be passed the parsed value and should return true if it respects the type constraints defined by this checker, or false if it does not.
Return values
mixedValue as parsed from the module's settings, or the default value if no value existed in the settings and it passed the type check.
Exceptions
Erebot::InvalidValueExceptionThe value parsed or the default value did not pass the type check.
Erebot::NotFoundException

Definition at line 313 of file Proxy.php.

Referenced by Erebot\Config\Proxy\parseBool(), Erebot\Config\Proxy\parseInt(), Erebot\Config\Proxy\parseReal(), and Erebot\Config\Proxy\parseString().

Erebot\Config\Proxy::parseString (   $module,
  $param,
  $default = null 
)

Definition at line 365 of file Proxy.php.

References Erebot\Config\Proxy\parseSomething().


The documentation for this class was generated from the following file: