classes/phing/system/util/Properties.php
Convenience class for reading and writing property files.
FIXME
- Add support for arrays (separated by ',')
- package
- phing.system.util
- version
- $Revision: 997 $
Properties
Methods



__construct(
array $properties
=
NULL
)
:
Constructor
Parameters
| Name |
Type |
Description |
| $properties |
array |
|



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



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



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



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



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



inVal(
string $val
)
:
mixedProcess values when being read in from properties file.
does things like convert "true" => true
Parameters
| Name |
Type |
Description |
| $val |
string |
Trimmed value. |
Returns



keys(
)
:
arrayReturns properties keys.
Use this for foreach() {} iterations, as this is
faster than looping through property values.
Returns



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



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



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.
Parameters
| Name |
Type |
Description |
| $filePath |
string |
|
Returns



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



setProperty(
string $key, mixed $value
)
:
mixedSet the value for a property.
Parameters
| Name |
Type |
Description |
| $key |
string |
|
| $value |
mixed |
|
Returns



store(
\PhingFile $file, string $header
=
null
)
:
voidStores current properties to specified file.
Parameters
| 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.
|
Details
- throws
- - 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.
Returns