# classes/phing/system/util/Properties.php

## \Properties
jump to top

Convenience class for reading and writing property files.

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

package
  phing.system.util
version
  $Revision: 997 $

### Properties

`$properties= 'array'`
Default value `array` Details

Type

### 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 ) : boolean`
Whether loaded properties array contains specified property name.
Parameters

Name | Type | Description
--- | --- | ---
$key |  |

Returns

Type | Description
--- | ---
boolean |

`get( string $prop ) : mixed`
Get 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

Type | Description
--- | ---
mixed |

Details

see
  \getProperty()

`getProperties( ) : array`
Returns copy of internal properties hash.

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

Returns

Type | Description
--- | ---
array |

`getProperty( string $prop ) : mixed`
Get value for specified property.

This is the same as get() method.

Parameters

Name | Type | Description
--- | --- | ---
$prop | string | The property name (key).

Returns

Type | Description
--- | ---
mixed |

Details

see
  \get()

`inVal( string $val ) : mixed`
Process values when being read in from properties file.

does things like convert "true" => true

Parameters

Name | Type | Description
--- | --- | ---
$val | string | Trimmed value.

Returns

Type | Description
--- | ---
mixed |

`isEmpty( ) : boolean`
Whether properties list is empty.
Returns

Type | Description
--- | ---
boolean |

`keys( ) : array`
Returns properties keys.

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

Returns

Type | Description
--- | ---
array |

`load( \PhingFile $file ) : void`
Load properties from a file.
Parameters

Name | Type | Description
--- | --- | ---
$file | \PhingFile |

Details

throws
  - if unable to read file.

`outVal( mixed $val ) : string`
Process 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

Type | Description
--- | ---
string |

`parse( string $filePath ) : array`
Replaces 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

Type | Description
--- | ---
array |

`propertyNames( ) : array`
Same as keys() function, returns an array of property names.
Returns

Type | Description
--- | ---
array |

`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 ) : mixed`
Set the value for a property.
Parameters

Name | Type | Description
--- | --- | ---
$key | string |
$value | mixed |

Returns

Type | Description
--- | ---
mixed |

`store( \PhingFile $file, string $header = null ) : void`
Stores 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( ) : string`
Create 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

Type | Description
--- | ---
string |

Documentation was generated by DocBlox 0.13.1.