Ini
class Ini
Initialization (INI) configuration parser that uses "October flavoured INI", with the following improvements:
- Parsing supports infinite array nesting
- Ability to render INI from a PHP array
Methods
Parses supplied INI contents in to a PHP array.
Parses supplied INI file contents in to a PHP array.
Expands a single array property from traditional INI syntax.
Formats an INI file string from an array
This method converts key names traditionally invalid, "][", and replaces them with a valid character "|" so parse_ini_string can function correctly. It also forces arrays to have unique indexes so their integrity is maintained.
This method takes the valid key name from pre processing and converts it back to a real PHP array. Eg:
- name[validation|regex|message] Converts to:
- name => [validation => [regex => [message]]]
Renders section properties.
Flatten a multi-dimensional associative array for traditional INI syntax.
Converts a PHP value to make it suitable for INI format.
Checks if the array is the final node in a multidimensional array.
Details
at line 23
array
parse(string $contents)
Parses supplied INI contents in to a PHP array.
at line 37
array
parseFile(string $fileName)
Parses supplied INI file contents in to a PHP array.
at line 52
array
expandProperty(array $array, string $key, mixed $value)
Expands a single array property from traditional INI syntax.
If no key is given to the method, the entire array will be replaced.
at line 81
string
render(array $vars = [], int $level = 1)
Formats an INI file string from an array
at line 117
protected string
parsePreProcess(string $contents)
This method converts key names traditionally invalid, "][", and replaces them with a valid character "|" so parse_ini_string can function correctly. It also forces arrays to have unique indexes so their integrity is maintained.
at line 165
protected array
parsePostProcess(array $array)
This method takes the valid key name from pre processing and converts it back to a real PHP array. Eg:
- name[validation|regex|message] Converts to:
- name => [validation => [regex => [message]]]
at line 185
protected string
renderProperties(array $vars = [])
Renders section properties.
at line 224
protected array
flattenProperties(array $array, string $prepend = '')
Flatten a multi-dimensional associative array for traditional INI syntax.
at line 251
protected string
evalValue(string $value)
Converts a PHP value to make it suitable for INI format.
Strings are escaped.
at line 268
protected bool
isFinalArray(array $array)
Checks if the array is the final node in a multidimensional array.
Checked supplied array is not associative and contains no array values.