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

Source for file Renderer.php

Documentation is available at Renderer.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2004 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available through the world-wide-web at the following url:           |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Frederic Poeydomenge <frederic.poeydomenge@free.fr>         |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id:
  20.  
  21. require_once 'PEAR.php';
  22.  
  23. /**
  24.  * A base class for Var_Dump renderers, must be inherited by all such.
  25.  *
  26.  * @package Var_Dump
  27.  * @category PHP
  28.  * @author Frederic Poeydomenge <frederic.poeydomenge@free.fr>
  29.  */
  30.  
  31. {
  32.  
  33.     /**
  34.      * Run-time configuration options.
  35.      * @var    array 
  36.      * @access public
  37.      */
  38.     var $options = array();
  39.  
  40.     /**
  41.      * Default configuration options.
  42.      * See Var_Dump/Renderer/*.php for the complete list of options
  43.      * @var    array 
  44.      * @access public
  45.      */
  46.     var $defaultOptions = array();
  47.  
  48.     /**
  49.      * Array containing the element family : start/finish group, start/finish element
  50.      * @var    array 
  51.      * @access public
  52.      */
  53.     var $family;
  54.  
  55.     /**
  56.      * Array containing the element depths
  57.      * @var    array 
  58.      * @access public
  59.      */
  60.     var $depth;
  61.  
  62.     /**
  63.      * Array containing the element types
  64.      * @var    array 
  65.      * @access public
  66.      */
  67.     var $type;
  68.  
  69.     /**
  70.      * Array containing the element values
  71.      * @var    array 
  72.      * @access public
  73.      */
  74.     var $value;
  75.  
  76.     /**
  77.      * Array containing the strlen of keys for all the nested arrays
  78.      * @var    array 
  79.      * @access public
  80.      */
  81.     var $keyLen;
  82.  
  83.     // {{{ constructor
  84.     /**
  85.      * Class constructor.
  86.      * @param  array  $options Parameters for the rendering.
  87.      * @access public
  88.      */
  89.     function Var_Dump_Renderer($options = array())
  90.     {
  91.         $this->setOptions($options);
  92.     }
  93.     // }}}
  94.  
  95.     // {{{ singleton()
  96.     /**
  97.      * Attempt to return a concrete singleton Var_Dump_Renderer instance.
  98.      * @param  string $mode    Name of the renderer.
  99.      * @param  array  $options Parameters for the rendering.
  100.      * @access public
  101.      */
  102.     function singleton($mode$options)
  103.     {
  104.         static $instances;
  105.         if (!isset($instances)) {
  106.             $instances = array();
  107.         }
  108.         if (!isset($instances[$mode])) {
  109.             @include_once 'Var_Dump/Renderer/' $mode '.php';
  110.             $className 'Var_Dump_Renderer_' $mode;
  111.             if (class_exists($className)) {
  112.                 $instances[$mode= new $className($options);
  113.             else {
  114.                 return PEAR::raiseError('Var_Dump: renderer "' $mode '" not found'TRUE);
  115.             }
  116.         else {
  117.             $obj $instances[$mode];
  118.             $obj->setOptions($options);
  119.         }
  120.         return $instances[$mode];
  121.     }
  122.     // }}}
  123.  
  124.     // {{{ setOptions()
  125.     /**
  126.      * Set run-time configuration options for the renderer
  127.      * @param  array  $options Run-time configuration options.
  128.      * @access public
  129.      */
  130.     function setOptions($options = array())
  131.     {
  132.         $this->options = array_merge (
  133.             $this->defaultOptions,
  134.             //$this->options,
  135.             $options
  136.         );
  137.     }
  138.     // }}}
  139.  
  140.     // {{{ initialize()
  141.     /**
  142.      * Initialize internal data structures for the rendering.
  143.      * @param  array $family Containing the element family.
  144.      * @param  array $depth  Containing the element depths.
  145.      * @param  array $type   Containing the element types.
  146.      * @param  array $value  Containing the element values.
  147.      * @param  array $keyLen Strlen of keys for all the nested arrays
  148.      * @access public
  149.      */
  150.     function initialize(&$family&$depth&$type&$value&$keyLen)
  151.     {
  152.         $this->family = $family;
  153.         $this->depth  = $depth;
  154.         $this->type   = $type;
  155.         $this->value  = $value;
  156.         $this->keyLen = $keyLen;
  157.     }
  158.     // }}}
  159.  
  160.     // {{{ toString()
  161.     /**
  162.      * Returns the string representation of a variable
  163.      * @return string The string representation of the variable.
  164.      * @access public
  165.      * @abstract
  166.      */
  167.     function toString()
  168.     {
  169.     }
  170.     // }}}
  171.  
  172. }
  173.  
  174. ?>

Documentation generated on Mon, 11 Mar 2019 10:16:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.