Math_Finance
[ class tree: Math_Finance ] [ index: Math_Finance ] [ all elements ]

Source for file Finance_FunctionParameters.php

Documentation is available at Finance_FunctionParameters.php

  1. <?php
  2. /**
  3.  * Singleton class to preserve given values of other variables in the callback functions
  4.  */
  5. class Math_Finance_FunctionParameters
  6. {
  7.     var $parameters = array();
  8.  
  9.     /**
  10.     * Constructor. Should be private, so used little hack.
  11.     *
  12.     * @param bool       Whether constructor has been called from a method of the class
  13.     * @param array      Parameters (variables values of the function) to be preserved
  14.     * @access private
  15.     */
  16.     function Math_Finance_FunctionParameters($called_from_get_instance = False$parameters = array())
  17.     {
  18.         // PHP4 hack
  19.         if (!$called_from_get_instance)
  20.             trigger_error("Cannot instantiate Math_Finance_FunctionParameters class directly (It's a Singleton)"E_USER_ERROR);
  21.         
  22.         foreach ($parameters as $name => $value{
  23.             $this->parameters[$name$value;
  24.         }
  25.     }
  26.  
  27.     /**
  28.     * Method to be called statically to create Singleton
  29.     *
  30.     * @param array      Parameters (variables values of the function) to be preserved
  31.     * @param bool       Whether the Singleton should be reset
  32.     * @static
  33.     * @access public
  34.     */
  35.     function &getInstance($parameters = array()$reset = False)
  36.     {
  37.         static $singleton;
  38.  
  39.         if ($reset$singleton = null;
  40.  
  41.         if (!is_object($singleton)) {
  42.             $singleton = new Math_Finance_FunctionParameters(True$parameters);
  43.         }
  44.  
  45.         return $singleton;
  46.     }
  47. }
  48. ?>

Documentation generated on Mon, 11 Mar 2019 15:40:20 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.