Convenience class for reading and writing property files.

FIXME - Add support for arrays (separated by ',')

package phing.system.util
version $Id: 8f34abee863fbe1d54b43c38d69a87940c7d000f $

 Methods

Constructor

__construct(array $properties) 

Parameters

$properties

array

Appends a value to a property if it already exists with a delimiter

append(string $key, mixed $value, string $delimiter) 

If the property does not, it just adds it.

Parameters

$key

string

$value

mixed

$delimiter

string

Whether loaded properties array contains specified property name.

containsKey($key) : boolean

Parameters

$key

Returns

boolean

Get value for specified property.

get(string $prop) : mixed

This function exists to provide a hashtable-like interface for properties.

see \global\getProperty()

Parameters

$prop

string

The property name (key).

Returns

mixed

Returns copy of internal properties hash.

getProperties() : array

Mostly for performance reasons, property hashes are often preferable to passing around objects.

Returns

array

Get value for specified property.

getProperty(string $prop) : mixed

This is the same as get() method.

see \global\get()

Parameters

$prop

string

The property name (key).

Returns

mixed

Whether properties list is empty.

isEmpty() : boolean

Returns

boolean

Returns properties keys.

keys() : array

Use this for foreach() {} iterations, as this is faster than looping through property values.

Returns

array

Load properties from a file.

load(\PhingFile $file) : void

Parameters

$file

\PhingFile

Exceptions

\IOException - if unable to read file.

Same as keys() function, returns an array of property names.

propertyNames() : array

Returns

array

Set the value for a property.

put(string $key, mixed $value) 

This function exists to provide hashtable-lie interface for properties.

Parameters

$key

string

$value

mixed

Set the value for a property.

setProperty(string $key, mixed $value) : mixed

Parameters

$key

string

$value

mixed

Returns

mixedOld property value or NULL if none was set.

Stores current properties to specified file.

store(\PhingFile $file, string $header) : void

Parameters

$file

\PhingFile

File to create/overwrite with properties.

$header

string

Header text that will be placed (within comments) at the top of properties file.

Exceptions

\IOException - on error writing properties file.

Create string representation that can be written to file and would be loadable using load() method.

toString() : string

Essentially this function creates a string representation of properties that is ready to write back out to a properties file. This is used by store() method.

Returns

string

Process values when being read in from properties file.

inVal(string $val) : mixed

does things like convert "true" => true

Parameters

$val

string

Trimmed value.

Returns

mixedThe new property value (may be boolean, etc.)

Process values when being written out to properties file.

outVal(mixed $val) : string

does things like convert true => "true"

Parameters

$val

mixed

The property value (may be boolean, etc.)

Returns

string

Replaces parse_ini_file() or better_parse_ini_file().

parse(string $filePath) : array

Saves a step since we don't have to parse and then check return value before throwing an error or setting class properties.

Parameters

$filePath

string

Returns

arrayProperties loaded from file (no prop replacements done yet).

 Properties

 

$file : \PhingFile
 

$properties