Class HTMLPurifier_StringHashParser

InheritanceHTMLPurifier_StringHashParser

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.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$default HTMLPurifier_StringHashParser

Public Methods

Hide inherited methods

MethodDescriptionDefined By
parseFile() Parses a file that contains a single string-hash. HTMLPurifier_StringHashParser
parseMultiFile() Parses a file that contains multiple string-hashes delimited by '----' HTMLPurifier_StringHashParser

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
parseHandle() Internal parser that acepts a file handle. HTMLPurifier_StringHashParser

Property Details

$default public property
public $default 'ID'

Method Details

parseFile() public method

Parses a file that contains a single string-hash.

public array parseFile ( $file )
$file string
parseHandle() protected method

Internal parser that acepts a file handle.

protected array parseHandle ( $fh )
$fh resource

File handle with pointer at start of valid string-hash

       block.
parseMultiFile() public method

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

public array parseMultiFile ( $file )
$file string