Aplus Framework Docs

XmlParser extends Parser
in package

Class XmlParser.

Table of Contents

parse()  : array<string|int, mixed>
Parses an XML file.
addChild()  : void
Recursively adds childs to an array tree.
checkConfig()  : void
Check for config issues.
getValue()  : array<int|string, mixed>|bool|float|int|string|null
Interprets a string value and returns it with a PHP type.
ksortRecursive()  : mixed
Sort arrays by keys recursively.
parseOrThrow()  : array<int|string, mixed>
parseValue()  : array<int|string, mixed>|bool|float|int|string|null

Methods

parse()

Parses an XML file.

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

path to the XML file

Tags
throws
ParserException
Return values
array<string|int, mixed>

The XML parsed data

addChild()

Recursively adds childs to an array tree.

protected static addChild(array<int|string, mixed> &$parent, array<int|string, mixed> $childs, mixed $value) : void
Parameters
$parent : array<int|string, mixed>

The main array, where the childs will be added

$childs : array<int|string, mixed>

Childs to add

$value : mixed

The last child value

Return values
void

checkConfig()

Check for config issues.

protected static checkConfig(mixed $config) : void
Parameters
$config : mixed

The parser configuration

Tags
throws
ParserException

If config is invalid

Return values
void

getValue()

Interprets a string value and returns it with a PHP type.

protected static getValue(string $value) : array<int|string, mixed>|bool|float|int|string|null
Parameters
$value : string

The input value

Return values
array<int|string, mixed>|bool|float|int|string|null

The output value

ksortRecursive()

Sort arrays by keys recursively.

protected static ksortRecursive(mixed $value) : mixed
Parameters
$value : mixed

The input value

Return values
mixed

The output value (sorted by keys if the $value is an array)

parseOrThrow()

protected static parseOrThrow(Closure $function) : array<int|string, mixed>
Parameters
$function : Closure
Tags
throws
ParserException

If config data can not be parsed

Return values
array<int|string, mixed>

parseValue()

protected static parseValue(array<int|string, mixed>|string $value) : array<int|string, mixed>|bool|float|int|string|null
Parameters
$value : array<int|string, mixed>|string
Return values
array<int|string, mixed>|bool|float|int|string|null

Search results