system/util/Properties.php
Convenience class for reading and writing property files.
FIXME - Add support for arrays (separated by ',')
- Package
- phing.system.util
- Version
- $Id: 577374dcb65bb9a2614bc80f605ce49600d64778 $
\Properties
Convenience class for reading and writing property files.
FIXME - Add support for arrays (separated by ',')
- Version
- $Id: 577374dcb65bb9a2614bc80f605ce49600d64778 $
Properties
Methods

__construct(
array $properties
=
NULL
)
:
voidConstructor
| Name | Type | Description |
|---|---|---|
| $properties | array |

append(
string $key, mixed $value, string $delimiter
=
','
)
:
voidAppends a value to a property if it already exists with a delimiter
If the property does not, it just adds it.
| Name | Type | Description |
|---|---|---|
| $key | string | |
| $value | mixed | |
| $delimiter | string |

containsKey(
$key
)
:
booleanWhether loaded properties array contains specified property name.
| Name | Type | Description |
|---|---|---|
| $key |
| Type | Description |
|---|---|
| boolean |

get(
string $prop
)
:
mixedGet value for specified property.
This function exists to provide a hashtable-like interface for properties.
| Name | Type | Description |
|---|---|---|
| $prop | string | The property name (key). |
| Type | Description |
|---|---|
| mixed |
- See
- \getProperty()

getProperties(
)
:
arrayReturns copy of internal properties hash.
Mostly for performance reasons, property hashes are often preferable to passing around objects.
| Type | Description |
|---|---|
| array |

getProperty(
string $prop
)
:
mixedGet value for specified property.
This is the same as get() method.
| Name | Type | Description |
|---|---|---|
| $prop | string | The property name (key). |
| Type | Description |
|---|---|
| mixed |
- See
- \get()

inVal(
string $val
)
:
mixedProcess values when being read in from properties file.
does things like convert "true" => true
| Name | Type | Description |
|---|---|---|
| $val | string | Trimmed value. |
| Type | Description |
|---|---|
| mixed | The new property value (may be boolean, etc.) |

keys(
)
:
arrayReturns properties keys.
Use this for foreach() {} iterations, as this is faster than looping through property values.
| Type | Description |
|---|---|
| array |

load(
\PhingFile $file
)
:
voidLoad properties from a file.
| Name | Type | Description |
|---|---|---|
| $file | \PhingFile |
| Exception | Description |
|---|---|
| \IOException | - if unable to read file. |

outVal(
mixed $val
)
:
stringProcess values when being written out to properties file.
does things like convert true => "true"
| Name | Type | Description |
|---|---|---|
| $val | mixed | The property value (may be boolean, etc.) |
| Type | Description |
|---|---|
| string |

parse(
string $filePath
)
:
arrayReplaces parse_ini_file() or better_parse_ini_file().
Saves a step since we don't have to parse and then check return value before throwing an error or setting class properties.
| Name | Type | Description |
|---|---|---|
| $filePath | string |
| Type | Description |
|---|---|
| array | Properties loaded from file (no prop replacements done yet). |

propertyNames(
)
:
arraySame as keys() function, returns an array of property names.
| Type | Description |
|---|---|
| array |

put(
string $key, mixed $value
)
:
voidSet the value for a property.
This function exists to provide hashtable-lie interface for properties.
| Name | Type | Description |
|---|---|---|
| $key | string | |
| $value | mixed |

setProperty(
string $key, mixed $value
)
:
mixedSet the value for a property.
| Name | Type | Description |
|---|---|---|
| $key | string | |
| $value | mixed |
| Type | Description |
|---|---|
| mixed | Old property value or NULL if none was set. |

store(
\PhingFile $file
=
null, string $header
=
null
)
:
voidStores current properties to specified file.
| Name | Type | Description |
|---|---|---|
| $file | \PhingFile | File to create/overwrite with properties. |
| $header | string | Header text that will be placed (within comments) at the top of properties file. |
| Exception | Description |
|---|---|
| \IOException | - on error writing properties file. |

toString(
)
:
stringCreate string representation that can be written to file and would be loadable using load() method.
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.
| Type | Description |
|---|---|
| string |