Class AbstractConfig - Stefanius67/Config GitHub Wiki
Full name: \SKien\Config\AbstractConfig
Implements: \SKien\Config\ConfigInterface
This is an abstract class that cannot be instantiated directly
Method | Description |
---|---|
getArray | Get the array specified by path. |
getBool | Get the boolean value specified by path. |
getConfig | Returns the internal array. |
getDate | Get the date value specified by path. |
getDateTime | Get the date and time value specified by path as unix timestamp. |
getFloat | Get the float value specified by path. |
getInt | Get the integer value specified by path. |
getString | Get the string value specified by path. |
getValue | Get the value specified by path. |
mergeWith | Merge this instance with values from onather config. |
setDateFormat | Set the format for date parameters. |
setDateTimeFormat | Set the format for datetime parameters. |
setPathSeparator | Set the separator character. |
Get the array specified by path.
public AbstractConfig::getArray(string $strPath, array $aDefault = []) : array
Parameters:
Parameter | Type | Description |
---|---|---|
strPath |
string | |
aDefault |
array |
Return Type: array
Get the boolean value specified by path.
public AbstractConfig::getBool(string $strPath, bool $bDefault = false) : bool
Parameters:
Parameter | Type | Description |
---|---|---|
strPath |
string | |
bDefault |
bool |
Return Type: bool
Returns the internal array.
public AbstractConfig::getConfig() : array
Return Type: array
Get the date value specified by path.
public AbstractConfig::getDate(string $strPath, int $default) : int
If the config file contains an integer, it is seen as unix timestamp.
If the config file contains the date as string, it is parsed with the internal
date format set by setDateFormat()
(default: 'Y-m-d')
Parameters:
Parameter | Type | Description |
---|---|---|
strPath |
string | |
default |
int | default value (unix timestamp) |
Return Type: int
date as unix timestamp
Get the date and time value specified by path as unix timestamp.
public AbstractConfig::getDateTime(string $strPath, int $default) : int
If the config file contains an integer, it is seen as unix timestamp.
If the config file contains the date-time as string, it is parsed with the internal
date format set by setDateTimeFormat()
(default: 'Y-m-d H:i')
Parameters:
Parameter | Type | Description |
---|---|---|
strPath |
string | |
default |
int | default value (unix timestamp) |
Return Type: int
unix timestamp
Get the float value specified by path.
public AbstractConfig::getFloat(string $strPath, float $fltDefault = 0.0) : float
Parameters:
Parameter | Type | Description |
---|---|---|
strPath |
string | |
fltDefault |
float |
Return Type: float
Get the integer value specified by path.
public AbstractConfig::getInt(string $strPath, int $iDefault) : int
Parameters:
Parameter | Type | Description |
---|---|---|
strPath |
string | |
iDefault |
int |
Return Type: int
Get the string value specified by path.
public AbstractConfig::getString(string $strPath, string $strDefault = '') : string
Parameters:
Parameter | Type | Description |
---|---|---|
strPath |
string | |
strDefault |
string |
Return Type: string
Get the value specified by path.
public AbstractConfig::getValue(string $strPath, mixed $default = null) : mixed
The path addresses a value within the configuration, which can be nested at
any depth (depending on the file format).
The individual levels are specified separated by a separator (default is '.').
The separator can be changed with setPathSeparator ()
.
Parameters:
Parameter | Type | Description |
---|---|---|
strPath |
string | the path to the value. |
default |
mixed | a default value that is returned if entry doesn't exist |
Return Type: mixed
See Also:
Merge this instance with values from onather config.
public AbstractConfig::mergeWith(\SKien\Config\AbstractConfig $oMerge) : void
Note that the elemenst of the config to merge with has allways higher priority than
the elements of this instance.
If both config contains elements with the same key, the value of this instance will be
replaced with the value of the config we merge with.
So keep allways the order in wich you merge several configs together in mind.
Parameters:
Parameter | Type | Description |
---|---|---|
oMerge |
\SKien\Config\AbstractConfig |
Set the format for date parameters.
public AbstractConfig::setDateFormat(string $strFormat) : void
See the formatting options DateTime::createFromFormat. In most cases, the same letters as for the date() can be used.
Parameters:
Parameter | Type | Description |
---|---|---|
strFormat |
string |
See Also:
Set the format for datetime parameters.
public AbstractConfig::setDateTimeFormat(string $strFormat) : void
See the formatting options DateTime::createFromFormat. In most cases, the same letters as for the date() can be used.
Parameters:
Parameter | Type | Description |
---|---|---|
strFormat |
string |
See Also:
Set the separator character.
public AbstractConfig::setPathSeparator(string $strSeparator) : void
Default the '.' is used as separator.
Parameters:
Parameter | Type | Description |
---|---|---|
strSeparator |
string |