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

Source for file XML.php

Documentation is available at XML.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 <fpoeydomenge at free dot fr>          |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id$
  20.  
  21. require_once 'Var_Dump/Renderer/Common.php';
  22.  
  23. /**
  24.  * A concrete renderer for Var_Dump
  25.  *
  26.  * Returns a representation of a variable in XML
  27.  * DTD : $PEARDIR/data/Var_Dump/renderer-xml.dtd
  28.  *
  29.  * @package Var_Dump
  30.  * @category PHP
  31.  * @author Frederic Poeydomenge <fpoeydomenge at free dot fr>
  32.  */
  33.  
  34. {
  35.  
  36.     /**
  37.      * Class constructor.
  38.      *
  39.      * @param array $options Parameters for the rendering.
  40.      * @access public
  41.      */
  42.     function Var_Dump_Renderer_XML($options = array())
  43.     {
  44.         $this->setOptions($options);
  45.     }
  46.  
  47.     /**
  48.      * Returns the string representation of a variable
  49.      *
  50.      * @return string The string representation of the variable.
  51.      * @access public
  52.      */
  53.     function toString()
  54.     {
  55.         if (count($this->family== 1{
  56.             return $this->_toString_Single();
  57.         else {
  58.             return $this->_toString_Array();
  59.         }
  60.     }
  61.  
  62.     /**
  63.      * Returns the string representation of a single variable
  64.      *
  65.      * @return string The string representation of a single variable.
  66.      * @access private
  67.      */
  68.     function _toString_Single()
  69.     {
  70.         return
  71.             '<element>' .
  72.             '<type>' htmlspecialchars($this->type[0]'</type>' .
  73.             '<value>' htmlspecialchars($this->value[0]'</value>' .
  74.             '</element>';
  75.     }
  76.  
  77.     /**
  78.      * Returns the string representation of a multiple variable
  79.      *
  80.      * @return string The string representation of a multiple variable.
  81.      * @access private
  82.      */
  83.     function _toString_Array()
  84.     {
  85.         $txt '';
  86.         $counter count($this->family);
  87.         $depth = 0;
  88.         for ($c = 0 ; $c $counter $c++{
  89.             switch ($this->family[$c]{
  90.                 case VAR_DUMP_START_GROUP :
  91.                     if ($this->depth[$c> 0{
  92.                         $txt .=
  93.                             $this->_spacer($depth'<type>group</type>' "\n" .
  94.                             $this->_spacer($depth++'<value>' "\n";
  95.                     }
  96.                     $txt .=
  97.                         $this->_spacer($depth.
  98.                         '<group caption="' htmlspecialchars($this->value[$c].
  99.                         '">' "\n";
  100.                     break;
  101.                 case VAR_DUMP_FINISH_GROUP :
  102.                     $txt .= $this->_spacer($depth'</group>' "\n";
  103.                     if ($this->depth[$c> 0{
  104.                         $txt .=
  105.                             $this->_spacer(--$depth'</value>' "\n" .
  106.                             $this->_spacer(--$depth'</element>' "\n";
  107.                         $depth--;
  108.                     }
  109.                     break;
  110.                 case VAR_DUMP_START_ELEMENT_NUM :
  111.                 case VAR_DUMP_START_ELEMENT_STR :
  112.                     $txt .=
  113.                         $this->_spacer(++$depth'<element>' "\n" .
  114.                         $this->_spacer(++$depth'<key>' .
  115.                         htmlspecialchars($this->value[$c].
  116.                         '</key>' "\n";
  117.                     break;
  118.                 case VAR_DUMP_FINISH_ELEMENT :
  119.                 case VAR_DUMP_FINISH_STRING :
  120.                     $txt .=
  121.                         $this->_spacer($depth'<type>' .
  122.                         htmlspecialchars($this->type[$c].
  123.                         '</type>' "\n".
  124.                         $this->_spacer($depth--'<value>' .
  125.                         htmlspecialchars($this->value[$c].
  126.                         '</value>' "\n" .
  127.                         $this->_spacer($depth--'</element>' "\n";
  128.                     break;
  129.             }
  130.         }
  131.         return $txt;
  132.     }
  133.  
  134.     /**
  135.      * Returns a spacer string to prefix the line
  136.      *
  137.      * @param integer $depth Depth level.
  138.      * @return string Spacer string
  139.      * @access private
  140.      */
  141.     function _spacer($depth{
  142.         return str_repeat(' '$depth << 1);
  143.     }
  144.  
  145. }
  146.  
  147. ?>

Documentation generated on Mon, 11 Mar 2019 14:23:44 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.