system/util/Properties.php

Show: inherited
Table of Contents

Convenience class for reading and writing property files.

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

Package
phing.system.util  
Version
$Id: 577374dcb65bb9a2614bc80f605ce49600d64778 $  

\Properties

Package: phing\system\util

Convenience class for reading and writing property files.

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

Version
$Id: 577374dcb65bb9a2614bc80f605ce49600d64778 $  

Properties

Propertyprivate\PhingFile  $file= 'null'

Default valuenullDetails
Type
\PhingFile
Propertyprivate  $properties= 'array()'
Default valuearray()Details
Type
n/a

Methods

methodpublic__construct( array $properties = NULL ) : void

Constructor

Parameters
Name Type Description
$properties array
methodpublicappend( string $key, mixed $value, string $delimiter = ',' ) : void

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
methodpubliccontainsKey(  $key ) : boolean

Whether loaded properties array contains specified property name.

Parameters
Name Type Description
$key
Returns
Type Description
boolean
methodpublicget( 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()  
methodpublicgetProperties( ) : array

Returns copy of internal properties hash.

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

Returns
Type Description
array
methodpublicgetProperty( 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()  
methodprotectedinVal( 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 The new property value (may be boolean, etc.)
methodpublicisEmpty( ) : boolean

Whether properties list is empty.

Returns
Type Description
boolean
methodpublickeys( ) : array

Returns properties keys.

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

Returns
Type Description
array
methodpublicload( \PhingFile $file ) : void

Load properties from a file.

Parameters
Name Type Description
$file \PhingFile
Throws
Exception Description
\IOException - if unable to read file.
methodprotectedoutVal( 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
methodprotectedparse( 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 Properties loaded from file (no prop replacements done yet).
methodpublicpropertyNames( ) : array

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

Returns
Type Description
array
methodpublicput( string $key, mixed $value ) : void

Set the value for a property.

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

Parameters
Name Type Description
$key string
$value mixed
methodpublicsetProperty( string $key, mixed $value ) : mixed

Set the value for a property.

Parameters
Name Type Description
$key string
$value mixed
Returns
Type Description
mixed Old property value or NULL if none was set.
methodpublicstore( \PhingFile $file = null, 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.

Throws
Exception Description
\IOException - on error writing properties file.
methodpublictoString( ) : 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.18.1.