Properties

Convenience class for reading and writing property files.

FIXME

  • Add support for arrays (separated by ',')
package

phing.system.util

version

$Id: c9344af8882ddc9df625c718212d03fbf2b68db1 $

Methods

Constructor

__construct(array $properties = null, \FileParserInterface $fileParser = null) 

Arguments

$properties

array

$fileParser

\FileParserInterface

_storeOutputStream

_storeOutputStream(\BufferedWriter $bw,  $comments) 

Arguments

$comments

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

Whether loaded properties array contains specified property name.

containsKey( $key) : boolean

Arguments

$key

Response

boolean

Get value for specified property.

get(string $prop) : mixed

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

see \Properties::getProperty()

Arguments

$prop

string

The property name (key).

Response

mixed

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 \Properties::get()

Arguments

$prop

string

The property name (key).

Response

mixed

Whether properties list is empty.

isEmpty() : boolean

Response

boolean

Returns properties keys.

keys() : array

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

Response

array

Load properties from a file.

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

Arguments

$file

\PhingFile

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

Parses the file given.

parse(\PhingFile $file) 

Arguments

$file

\PhingFile

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

propertyNames() : array

Response

array

Set the value for a property.

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

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

Arguments

$key

string

$value

mixed

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.

Stores current properties to specified file.

store(\PhingFile $file = null, string $header = null) : void
Throws
\IOException
  • 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.

storeOutputStream

storeOutputStream(\OutputStream $os,  $comments) 

Arguments

$comments

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

writeComments

writeComments(\BufferedWriter $bw,  $comments) 
static

Arguments

$comments

Properties

properties

properties : 

Type(s)

fileParser

fileParser : \FileParserInterface
var

Type(s)

\FileParserInterface

file

file : \PhingFile
var

Type(s)

\PhingFile