Config
extends ArrayObject
in package
Config class
Tags
Table of Contents
Properties
- $allowChanges : bool
- Flag for whether changes are allowed after object instantiation
- $data : mixed
- Array data
Methods
- __construct() : mixed
- Constructor
- __get() : mixed
- Get a value
- __isset() : bool
- Is value set
- __serialize() : mixed
- Serialize magic method
- __set() : static
- Set a value
- __unserialize() : ArrayObject
- Unserialize magic method
- __unset() : void
- Unset a value
- changesAllowed() : bool
- Return if changes to the config are allowed.
- contains() : bool
- Determine if an item exists in the array
- count() : int
- Method to get the count of data in the collection
- createFromData() : self
- Method to create a config object from parsed data
- createFromJson() : ArrayObject
- Create array object from JSON string
- createFromSerialized() : ArrayObject
- Create array object from serialized string
- current() : mixed
- Get the current item of the array
- first() : mixed
- Get the first item of the array
- getIterator() : ArrayIterator
- Method to iterate over the array object
- join() : string
- Join the array values into a string
- jsonSerialize() : string
- JSON serialize the array object
- jsonUnserialize() : ArrayObject
- Unserialize a JSON string
- key() : mixed
- Get the key of the current item of the array
- ksort() : array<string|int, mixed>
- Sort array by keys
- ksortDesc() : static
- Sort array by keys, descending
- last() : mixed
- Get the last item of the array
- merge() : Config
- Merge the values of another config object into this one.
- mergeFromData() : Config
- Merge the values of another config object into this one.
- next() : mixed
- Get the next item of the array
- offsetExists() : bool
- ArrayAccess offsetExists
- offsetGet() : mixed
- ArrayAccess offsetGet
- offsetSet() : void
- ArrayAccess offsetSet
- offsetUnset() : void
- ArrayAccess offsetUnset
- parseData() : array<string|int, mixed>
- Method to parse data and return config values
- render() : string
- Render data to a string format
- serialize() : string
- Serialize the array object
- sort() : array<string|int, mixed>
- Sort array
- sortDesc() : static
- Sort array descending
- split() : static
- Split a string into an array object
- toArray() : array<string|int, mixed>
- Get the values as an array
- toArrayObject() : ArrayObject|ArrayObject
- Get the config values as an array
- toIni() : string
- Get the config values as an INI string
- toJson() : string
- Get the config values as a JSON string
- toXml() : string
- Get the config values as an XML string
- toYaml() : string
- Get the config values as an YAML string
- uksort() : array<string|int, mixed>
- Sort array by user-defined callback using keys
- unserialize() : ArrayObject
- Unserialize a string
- usort() : static
- Sort array by user-defined callback
- writeToFile() : void
- Write the config data to file
- arrayToIni() : string
- Method to convert array to INI
- arrayToXml() : void
- Method to convert array to XML
- arrayToYaml() : string
- Method to convert array to Yaml
Properties
$allowChanges
Flag for whether changes are allowed after object instantiation
protected
bool
$allowChanges
= false
$data
Array data
protected
mixed
$data
= null
Methods
__construct()
Constructor
public
__construct([mixed $data = [] ][, bool $changes = false ]) : mixed
Instantiate a config object
Parameters
- $data : mixed = []
- $changes : bool = false
Tags
__get()
Get a value
public
__get(string $name) : mixed
Parameters
- $name : string
__isset()
Is value set
public
__isset(string $name) : bool
Parameters
- $name : string
Return values
bool__serialize()
Serialize magic method
public
__serialize() : mixed
__set()
Set a value
public
__set([string|null $name = null ][, mixed $value = null ]) : static
Parameters
- $name : string|null = null
- $value : mixed = null
Return values
static__unserialize()
Unserialize magic method
public
__unserialize(array<string|int, mixed> $data) : ArrayObject
Parameters
- $data : array<string|int, mixed>
Return values
ArrayObject__unset()
Unset a value
public
__unset(string $name) : void
Parameters
- $name : string
Tags
changesAllowed()
Return if changes to the config are allowed.
public
changesAllowed() : bool
Return values
boolcontains()
Determine if an item exists in the array
public
contains(mixed $key[, bool $strict = false ]) : bool
Parameters
- $key : mixed
- $strict : bool = false
Return values
boolcount()
Method to get the count of data in the collection
public
count() : int
Return values
intcreateFromData()
Method to create a config object from parsed data
public
static createFromData([mixed $data = [] ][, bool $changes = false ]) : self
Parameters
- $data : mixed = []
- $changes : bool = false
Return values
selfcreateFromJson()
Create array object from JSON string
public
static createFromJson(string $jsonString[, int $depth = 512 ][, int $options = 0 ]) : ArrayObject
Parameters
- $jsonString : string
- $depth : int = 512
- $options : int = 0
Return values
ArrayObjectcreateFromSerialized()
Create array object from serialized string
public
static createFromSerialized(string $string) : ArrayObject
Parameters
- $string : string
Tags
Return values
ArrayObjectcurrent()
Get the current item of the array
public
current() : mixed
first()
Get the first item of the array
public
first() : mixed
getIterator()
Method to iterate over the array object
public
getIterator() : ArrayIterator
Return values
ArrayIteratorjoin()
Join the array values into a string
public
join(string $glue[, string $finalGlue = '' ]) : string
Parameters
- $glue : string
- $finalGlue : string = ''
Return values
stringjsonSerialize()
JSON serialize the array object
public
jsonSerialize([int $options = 0 ][, int $depth = 512 ]) : string
Parameters
- $options : int = 0
- $depth : int = 512
Return values
stringjsonUnserialize()
Unserialize a JSON string
public
jsonUnserialize(string $jsonString[, int $depth = 512 ][, int $options = 0 ]) : ArrayObject
Parameters
- $jsonString : string
- $depth : int = 512
- $options : int = 0
Return values
ArrayObjectkey()
Get the key of the current item of the array
public
key() : mixed
ksort()
Sort array by keys
public
ksort([int $flags = SORT_REGULAR ][, bool $descending = false ]) : array<string|int, mixed>
Parameters
- $flags : int = SORT_REGULAR
- $descending : bool = false
Return values
array<string|int, mixed>ksortDesc()
Sort array by keys, descending
public
ksortDesc([int $flags = SORT_REGULAR ]) : static
Parameters
- $flags : int = SORT_REGULAR
Return values
staticlast()
Get the last item of the array
public
last() : mixed
merge()
Merge the values of another config object into this one.
public
merge(mixed $data[, bool $preserve = false ]) : Config
By default, existing values are overwritten, unless the $preserve flag is set to true.
Parameters
- $data : mixed
- $preserve : bool = false
Tags
Return values
ConfigmergeFromData()
Merge the values of another config object into this one.
public
mergeFromData(mixed $data[, bool $preserve = false ]) : Config
By default, existing values are overwritten, unless the $preserve flag is set to true.
Parameters
- $data : mixed
- $preserve : bool = false
Tags
Return values
Confignext()
Get the next item of the array
public
next() : mixed
offsetExists()
ArrayAccess offsetExists
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
booloffsetGet()
ArrayAccess offsetGet
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
offsetSet()
ArrayAccess offsetSet
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
offsetUnset()
ArrayAccess offsetUnset
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
parseData()
Method to parse data and return config values
public
static parseData(mixed $data) : array<string|int, mixed>
Parameters
- $data : mixed
Return values
array<string|int, mixed>render()
Render data to a string format
public
render(string $format) : string
Parameters
- $format : string
Tags
Return values
stringserialize()
Serialize the array object
public
serialize([bool $self = false ]) : string
Parameters
- $self : bool = false
Return values
stringsort()
Sort array
public
sort([int $flags = SORT_REGULAR ][, bool $assoc = true ][, bool $descending = false ]) : array<string|int, mixed>
Parameters
- $flags : int = SORT_REGULAR
- $assoc : bool = true
- $descending : bool = false
Return values
array<string|int, mixed>sortDesc()
Sort array descending
public
sortDesc([int $flags = SORT_REGULAR ][, bool $assoc = true ]) : static
Parameters
- $flags : int = SORT_REGULAR
- $assoc : bool = true
Return values
staticsplit()
Split a string into an array object
public
static split(string $string, string $separator[, int $limit = PHP_INT_MAX ]) : static
Parameters
- $string : string
- $separator : string
- $limit : int = PHP_INT_MAX
Return values
statictoArray()
Get the values as an array
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>toArrayObject()
Get the config values as an array
public
toArrayObject([mixed $native = false ]) : ArrayObject|ArrayObject
Parameters
- $native : mixed = false
Tags
Return values
ArrayObject|ArrayObjecttoIni()
Get the config values as an INI string
public
toIni() : string
Return values
stringtoJson()
Get the config values as a JSON string
public
toJson() : string
Return values
stringtoXml()
Get the config values as an XML string
public
toXml() : string
Return values
stringtoYaml()
Get the config values as an YAML string
public
toYaml() : string
Return values
stringuksort()
Sort array by user-defined callback using keys
public
uksort(mixed $callback) : array<string|int, mixed>
Parameters
- $callback : mixed
Return values
array<string|int, mixed>unserialize()
Unserialize a string
public
unserialize(string $string) : ArrayObject
Parameters
- $string : string
Tags
Return values
ArrayObjectusort()
Sort array by user-defined callback
public
usort(mixed $callback[, bool $assoc = true ]) : static
Parameters
- $callback : mixed
- $assoc : bool = true
Return values
staticwriteToFile()
Write the config data to file
public
writeToFile(string $filename) : void
Parameters
- $filename : string
Tags
arrayToIni()
Method to convert array to INI
protected
arrayToIni(array<string|int, mixed> $array) : string
Parameters
- $array : array<string|int, mixed>
Return values
stringarrayToXml()
Method to convert array to XML
protected
arrayToXml(array<string|int, mixed> $array, SimpleXMLElement &$config) : void
Parameters
- $array : array<string|int, mixed>
- $config : SimpleXMLElement
arrayToYaml()
Method to convert array to Yaml
protected
arrayToYaml(array<string|int, mixed> $array) : string
Parameters
- $array : array<string|int, mixed>