# classes/phing/filters/ReplaceTokens.php

## \ReplaceTokens
jump to top

Replaces tokens in the original input with user-supplied values.

Example:

    ;

Or:

Extends from
  \BaseParamFilterReader
Implements
  \ChainableReader
see
  \BaseParamFilterReader
access
  public
author
  Yannick Lecaillez
author
  hans lellelid, hans@velum.net
copyright
  © 2003 seasonfive. All rights reserved
package
  phing.filters
version
  $Revision: 1039 $ $Date: 2011-02-20 20:19:21 +0100 (Sun, 20 Feb 2011) $

### Constants

`string DEFAULT_BEGIN_TOKEN = '@'`

Default "begin token" character.

  string

`string DEFAULT_END_TOKEN = '@'`

Default "end token" character.

  string

### Properties

`array $_alltokens= 'null'`

Array holding all tokens given directly to the Filter and those passed via a TokenSource.

Default value `null` Details

Type
  array

`string $_beginToken= '@'`

Character marking the beginning of a token.

Default value`@`Details

Type
  string

`string $_endToken= '@'`

Character marking the end of a token.

Default value`@`Details

Type
  string

`string $_queuedData= 'null'`

[Deprecated] Data that must be read from, if not null.

Default value `null` Details

Type
  string

`array $_tokens= 'array'`

Array to hold the replacee-replacer pairs (String to String).

Default value `array` Details

Type
  array

`array $_tokensources= 'array'`

Array to hold the token sources that make tokens from different sources available

Default value `array` Details

Type
  array

### Methods

`_initialize( ) :`
Initializes tokens and loads the replacee-replacer hashtable.

This method is only called when this filter is used through a tag in build file.

`chain( object $reader ) : object`
Creates a new ReplaceTokens using the passed in Reader for instantiation.
Parameters

Name | Type | Description
--- | --- | ---
$reader | object | A Reader object providing the underlying stream. Must not be `null`.

Returns

Type | Description
--- | ---
object |

`createToken( ) : object`
Adds a token element to the map of tokens to replace.
Returns

Type | Description
--- | ---
object |

`createTokensource( ) : object`
Adds a token source to the sources of this filter.
Returns

Type | Description
--- | ---
object |

`getBeginToken( ) : string`
Returns the "begin token" character.
Returns

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

`getEndToken( ) : \the`
Returns the "end token" character.
Returns

Type | Description
--- | ---
\the |

`getTokens( ) : array`
Returns the map of tokens which will be replaced.

; used by ReplaceTokens::chain()

Returns

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

`getTokensources( ) : array`
Returns the token sources used by this filter; used by ReplaceTokens::chain()
Returns

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

`read( $len = null ) : mixed`
Returns stream with tokens having been replaced with appropriate values.

If a replacement value is not found for a token, the token is left in the stream.

Parameters

Name | Type | Description
--- | --- | ---
$len |  |

Returns

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

`replaceTokenCallback( array $matches ) : string`
Performs lookup on key and returns appropriate replacement string.
Parameters

Name | Type | Description
--- | --- | ---
$matches | array | Array of 1 el containing key to search for.

Returns

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

Details

access
  private

`setBeginToken( string $beginToken ) :`
Sets the "begin token" character.
Parameters

Name | Type | Description
--- | --- | ---
$beginToken | string | the character used to denote the beginning of a token.

`setEndToken( string $endToken ) :`
Sets the "end token" character.
Parameters

Name | Type | Description
--- | --- | ---
$endToken | string | the character used to denote the end of a token

`setTokens( array $tokens ) :`
Sets the map of tokens to replace.

; used by ReplaceTokens::chain()

Parameters

Name | Type | Description
--- | --- | ---
$tokens | array | A map (String->String) of token keys to replacement values. Must not be `null`.

`setTokensources( array $sources ) :`
Sets the tokensources to use; used by ReplaceTokens::chain()
Parameters

Name | Type | Description
--- | --- | ---
$sources | array | An array of token sources.

## \Token
jump to top

Holds a token.

package
  phing.filters

### Properties

`string $_key= ''`

Token key.

Details

Type
  string

`string $_value= ''`

Token value.

Details

Type
  string

### Methods

`addText( string $value ) :`
Sets the token value from text.
Parameters

Name | Type | Description
--- | --- | ---
$value | string | The value for this token. Must not be `null`.

`getKey( ) : string`
Returns the key for this token.
Returns

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

`getValue( ) : string`
Returns the value for this token.
Returns

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

`setKey( string $key ) :`
Sets the token key.
Parameters

Name | Type | Description
--- | --- | ---
$key | string | The key for this token. Must not be `null`.

`setValue( string $value ) :`
Sets the token value.
Parameters

Name | Type | Description
--- | --- | ---
$value | string | The value for this token. Must not be `null`.

Documentation was generated by DocBlox 0.13.1.