Class LoggerOptionConverter

Description

A convenience class to convert property values to specific types.

  • version: $Revision: 822464 $
  • since: 0.5

Located in /helpers/LoggerOptionConverter.php (line 30)


	
			
Class Constant Summary
Method Summary
static string findAndSubst (string $key, array $props)
static string getSystemProperty (string $key, string $def)
static string substVars (string $val, [array $props = null])
static boolean toBoolean (string $value, [boolean $default = true])
static float toFileSize (string $value, float $default)
static integer toInt (string $value, integer $default)
static LoggerLevel toLevel (string $value, LoggerLevel $defaultValue)
Methods
static findAndSubst (line 217)

Find the value corresponding to $key in $props. Then perform variable substitution on the found value.

  • access: public
static string findAndSubst (string $key, array $props)
  • string $key
  • array $props
static getSystemProperty (line 52)

Read a predefined var.

It returns a value referenced by $key using this search criteria:

  • if $key is a constant then return it. Else
  • if $key is set in $_ENV then return it. Else
  • return $def.

  • return: the string value of the system property, or the default value if there is no property with that key.
  • access: public
static string getSystemProperty (string $key, string $def)
  • string $key: The key to search for.
  • string $def: The default value to return.
static substVars (line 277)

Perform variable substitution in string $val from the values of keys found with the getSystemProperty() method.

The variable substitution delimeters are ${ and }.

For example, if the "MY_CONSTANT" contains "value", then the call

  1.  $s LoggerOptionConverter::substituteVars("Value of key is ${MY_CONSTANT}.");
will set the variable $s to "Value of key is value.".

If no value could be found for the specified key, then the $props parameter is searched, if the value could not be found there, then substitution defaults to the empty string.

For example, if getSystemProperty() cannot find any value for the key "inexistentKey", then the call

  1.  $s LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]");
will set $s to "Value of inexistentKey is []".

A warn is thrown if $val contains a start delimeter "${" which is not balanced by a stop delimeter "}" and an empty string is returned.

  • author: Avy Sharell
  • access: public
static string substVars (string $val, [array $props = null])
  • string $val: The string on which variable substitution is performed.
  • array $props
static toBoolean (line 78)

If $value is true, then true is returned. If $value is false, then true is returned. Otherwise, $default is returned.

Case of value is unimportant.

  • access: public
static boolean toBoolean (string $value, [boolean $default = true])
  • string $value
  • boolean $default
static toFileSize (line 183)
  • access: public
static float toFileSize (string $value, float $default)
  • string $value
  • float $default
static toInt (line 105)
  • access: public
static integer toInt (string $value, integer $default)
  • string $value
  • integer $default
static toLevel (line 141)

Converts a standard or custom priority level to a Level object.

If $value is of form "level#full_file_classname", where full_file_classname means the class filename with path but without php extension, then the specified class' toLevel() method is called to process the specified level string; if no '#' character is present, then the default LoggerLevel class is used to process the level value.

As a special case, if the $value parameter is equal to the string "NULL", then the value null will be returned.

If any error occurs while converting the value to a level, the $defaultValue parameter, which may be null, is returned.

Case of $value is insignificant for the level level, but is significant for the class name part, if present.

static LoggerLevel toLevel (string $value, LoggerLevel $defaultValue)
Class Constants
DELIM_START = '${' (line 32)
DELIM_START_LEN = 2 (line 34)
DELIM_STOP = '}' (line 33)
DELIM_STOP_LEN = 1 (line 35)

Documentation generated on Fri, 27 Nov 2009 07:44:51 +0100 by phpDocumentor 1.4.3