Properties

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 = NULL) 

Arguments

$properties

array

Load properties from a file.

load(\PhingFile $file) : void
throws
  • if unable to read file.

Arguments

$file

\PhingFile

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.

Arguments

$filePath

string

Response

array

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

Process values when being read in from properties file.

inVal(string $val) : mixed

does things like convert "true" => true

Arguments

$val

string

Trimmed value.

Response

mixed

The 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"

Arguments

$val

mixed

The property value (may be boolean, etc.)

Response

string

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.

Response

string

Stores current properties to specified file.

store(\PhingFile $file = null, string $header = null) : void
throws
  • on error writing properties file.

Arguments

$file

\PhingFile

File to create/overwrite with properties.

$header

string

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

Returns copy of internal properties hash.

getProperties() : array

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

Response

array

Get value for specified property.

getProperty(string $prop) : mixed

This is the same as get() method.

see \get()

Arguments

$prop

string

The property name (key).

Response

mixed

Get value for specified property.

get(string $prop) : mixed

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

see \getProperty()

Arguments

$prop

string

The property name (key).

Response

mixed

Set the value for a property.

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

Arguments

$key

string

$value

mixed

Response

mixed

Old property value or NULL if none was set.

Set the value for a property.

put(string $key, mixed $value) 

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

Arguments

$key

string

$value

mixed

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.

Arguments

$key

string

$value

mixed

$delimiter

string

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

propertyNames() : array

Response

array

Whether loaded properties array contains specified property name.

containsKey($key) : boolean

Arguments

$key

Response

boolean

Returns properties keys.

keys() : array

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

Response

array

Whether properties list is empty.

isEmpty() : boolean

Response

boolean

Properties

properties

properties : 

file

file : \PhingFile
var

Type(s)

\PhingFile