HumHub Documentation (unofficial)

HTMLPurifier_StringHashParser
in package

Parses string hash files. File format is as such:

DefaultKeyValue KEY: Value KEY2: Value2 --MULTILINE-KEY-- Multiline value.

Which would output something similar to:

 array(
     'ID' => 'DefaultKeyValue',
     'KEY' => 'Value',
     'KEY2' => 'Value2',
     'MULTILINE-KEY' => "Multiline\nvalue.\n",
 )

We use this as an easy to use file-format for configuration schema files, but the class itself is usage agnostic.

You can use ---- to forcibly terminate parsing of a single string-hash; this marker is used in multi string-hashes to delimit boundaries.

Table of Contents

Properties

$default  : mixed

Methods

parseFile()  : array<string|int, mixed>
Parses a file that contains a single string-hash.
parseMultiFile()  : array<string|int, mixed>
Parses a file that contains multiple string-hashes delimited by '----'
parseHandle()  : array<string|int, mixed>
Internal parser that acepts a file handle.

Properties

Methods

parseFile()

Parses a file that contains a single string-hash.

public parseFile(string $file) : array<string|int, mixed>
Parameters
$file : string
Return values
array<string|int, mixed>

parseMultiFile()

Parses a file that contains multiple string-hashes delimited by '----'

public parseMultiFile(string $file) : array<string|int, mixed>
Parameters
$file : string
Return values
array<string|int, mixed>

parseHandle()

Internal parser that acepts a file handle.

protected parseHandle(resource $fh) : array<string|int, mixed>
Parameters
$fh : resource

File handle with pointer at start of valid string-hash block.

Tags
note

While it's possible to simulate in-memory parsing by using custom stream wrappers, if such a use-case arises we should factor out the file handle into its own class.

Return values
array<string|int, mixed>

        
On this page

Search results