Documentation

Ini
in package

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
Tags
author

Alexey Bobkov, Samuel Georges

Table of Contents

expandProperty()  : array<string|int, mixed>
Expands a single array property from traditional INI syntax.
parse()  : array<string|int, mixed>
Parses supplied INI contents in to a PHP array.
parseFile()  : array<string|int, mixed>
Parses supplied INI file contents in to a PHP array.
render()  : string
Formats an INI file string from an array
evalValue()  : string
Converts a PHP value to make it suitable for INI format.
flattenProperties()  : array<string|int, mixed>
Flatten a multi-dimensional associative array for traditional INI syntax.
isFinalArray()  : bool
Checks if the array is the final node in a multidimensional array.
parsePostProcess()  : array<string|int, mixed>
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]]]
parsePreProcess()  : string
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.
renderProperties()  : string
Renders section properties.

Methods

expandProperty()

Expands a single array property from traditional INI syntax.

public expandProperty(array<string|int, mixed> &$array, string $key, mixed $value) : array<string|int, mixed>

If no key is given to the method, the entire array will be replaced.

Parameters
$array : array<string|int, mixed>
$key : string
$value : mixed
Return values
array<string|int, mixed>

parse()

Parses supplied INI contents in to a PHP array.

public parse(string $contents) : array<string|int, mixed>
Parameters
$contents : string

INI contents to parse.

Return values
array<string|int, mixed>

parseFile()

Parses supplied INI file contents in to a PHP array.

public parseFile(string $fileName) : array<string|int, mixed>
Parameters
$fileName : string

File to read contents and parse.

Return values
array<string|int, mixed>

render()

Formats an INI file string from an array

public render([array<string|int, mixed> $vars = [] ][, int $level = 1 ]) : string
Parameters
$vars : array<string|int, mixed> = []

Data to format.

$level : int = 1

Specifies the level of array value.

Return values
string

Returns the INI file string.

evalValue()

Converts a PHP value to make it suitable for INI format.

protected evalValue(string $value) : string

Strings are escaped.

Parameters
$value : string

Specifies the value to process

Return values
string

Returns the processed value

flattenProperties()

Flatten a multi-dimensional associative array for traditional INI syntax.

protected flattenProperties(array<string|int, mixed> $array[, string $prepend = '' ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
$prepend : string = ''
Return values
array<string|int, mixed>

isFinalArray()

Checks if the array is the final node in a multidimensional array.

protected isFinalArray(array<string|int, mixed> $array) : bool

Checked supplied array is not associative and contains no array values.

Parameters
$array : array<string|int, mixed>
Return values
bool

parsePostProcess()

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]]]

protected parsePostProcess(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
Return values
array<string|int, mixed>

parsePreProcess()

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.

protected parsePreProcess(string $contents) : string
Parameters
$contents : string

INI contents to parse.

Return values
string

renderProperties()

Renders section properties.

protected renderProperties([array<string|int, mixed> $vars = [] ]) : string
Parameters
$vars : array<string|int, mixed> = []
Return values
string

Search results