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

Documentation generated on Mon, 11 Mar 2019 13:51:33 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.