com\setasign\SetaFramework\Config
Config Class Config
File: /SetaFramework/src/Config/Config.php
Class hierarchy
Implements
Summary
Methods
- __construct()
- __clone()
- __get()
- __isset()
- __set()
- __toString()
- __unset()
- count()
- delete()
- filter()
- get()
- getChain()
- getIterator()
- getSubConfig()
- has()
- hasChain()
- in()
- isReadOnly()
- isSubConfig()
- jsonSerialize()
- keys()
- ksort()
- offsetExists()
- offsetGet()
- offsetSet()
- offsetUnset()
- push()
- rand()
- search()
- set()
- setReadOnly()
- sort()
- toArray()
- values()
Properties
Static Methods
createReader()
array $params = array ( )
Parameters
- $file : string
- $params : array
read()
array $params = array ( ),
bool $readOnly = false
Reads a config file.
Which $params are possible depends on $file. The params will be passed in the given order. Only the internal order will be used, not the keys.
Supported file types: .ini, .xml, .json, .php
Parameters
- $file : string
- $params : array
- $readOnly : bool
Return Values
Result depends on $createConfig; If false $readOnly won't be used.
Methods
__construct()
Constructor
Parameters
- $config : array|Reader\ReaderInterface
- $readOnly : bool
__get()
Magic get method to get a value
Parameters
- $key : int|string
Exceptions
Throws \InvalidArgumentException
delete()
Deletes an entry or throws an exception if the config is marked as readOnly or the entry does not exist
Parameters
- $key : int|string
Exceptions
Throws \InvalidArgumentException
Throws \BadMethodCallException
getChain()
Helper method to get a value or the default of a nested config.
If the keyChain does not exist like specified the default will be returned.
$keyChain can be defined as string: '->' is the delimiter of the keys.
Parameters
- $keyChain : int|string|array
- $default : mixed
The default value.
rand()
Picks one or more random entries out of an array, and returns the key (or keys) of the random entries.
Parameters
- $numReq : int
Specifies how many entries should be picked.
Return Values
When picking only one entry, array_rand() returns the key for a random entry. Otherwise, an array of keys for the random entries is returned. This is done so that random keys can be picked from the array as well as random values. Trying to pick more elements than there are in the array will result in an E_WARNING level error, and NULL will be returned.
search()
Searches the array for a given value and returns the corresponding key if successful
Parameters
- $needle : mixed
The searched value.
- $strict : bool
If TRUE then the method will search for identical elements in the haystack. This means it will also check the types of the needle in the haystack, and objects must be the same instance.
set()
Sets a value or throws an exception if the config is marked as readOnly
Parameters
- $key : int|string
- $value : mixed
Exceptions
Throws \BadMethodCallException
setReadOnly()
Sets the read-only flag on this and all underlaying config-objects
Parameters
- $readOnly : bool
