Source for file Constant.class.php

Documentation is available at Constant.class.php

  1. <?php
  2. /**
  3.  * Gumbo Library Framework
  4.  *
  5.  * LICENSE
  6.  * This library is being released under the terms of the New BSD License.  A
  7.  * copy of the license is packaged with the software (LICENSE.txt).  If no
  8.  * copy is found, a copy of the license template can be found at:
  9.  * http://www.opensource.org/licenses/bsd-license.php
  10.  * 
  11.  * @category Gumbo
  12.  * @package Debug
  13.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  14.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  15.  * @author Michael Luster <mluster79@yahoo.com>
  16.  * @link http://sourceforge.net/projects/phpgumbo
  17.  * @version 0.0.1
  18.  */
  19.  
  20. /**
  21.  * Debug Server Report - Constants
  22.  *
  23.  * @category Gumbo
  24.  * @package Debug
  25.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  26.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  27.  * @author Michael Luster <mluster79@yahoo.com>
  28.  * @link http://sourceforge.net/projects/phpgumbo
  29.  * @desc Debug Server Report - Constants
  30.  * @version 0.0.1
  31.  */
  32.  
  33. gumbo_load ("Interface_Debug_Server_Report");
  34.  
  35. class Gumbo_Debug_Server_Constant implements Gumbo_Interface_Debug_Server_Report {
  36.     
  37.     /** @var bool $_php include defined PHP Constants */
  38.     private $_php = false;
  39.     
  40.     
  41.     
  42.     /**
  43.      * Constructor
  44.      * @param bool $php include defined PHP Constants
  45.      */
  46.     public function __construct ($php=null{
  47.         if (!is_null ($php)) $this->setPhp ($php)}
  48.     }
  49.     
  50.     
  51.     
  52.     /** ACTION METHODS **/
  53.     /**
  54.      * Runs the Report
  55.      * @return string 
  56.      */
  57.     public function run ({
  58.         $txt "<div class=\"debug\">\n";
  59.         $txt .= "\t<ul>Defined Constants\n";
  60.         
  61.         $restrict $this->getPhp ();
  62.         foreach (get_defined_constants (as $key=>$val{
  63.             if ($restrict && $key != "GUMBO_HOME"{
  64.                 continue;
  65.             }
  66.             $txt .= "\t\t<li><b>{$key} ::</b> {$val}</li>\n";
  67.             $restrict false;
  68.         }
  69.         
  70.         $txt .= "\t</ul>\n";
  71.         return $txt;
  72.     }
  73.     
  74.     
  75.     
  76.     /** MUTATOR METHODS **/
  77.     /**
  78.      * Sets if to include defined PHP Constants
  79.      * @param bool $php 
  80.      * @throws Gumbo_Exception
  81.      */
  82.     public function setPhp ($php{
  83.         try {
  84.             // verify precondition
  85.             if (!is_bool ($php)) {
  86.                 throw new Gumbo_Exception ("Invalid Argument 'php:bool' => {$php}:gettype ($php));
  87.             }
  88.             
  89.             $this->_php = $php;
  90.         catch (Gumbo_Exception $e{
  91.             $e->setFunction (__METHOD__);
  92.             gumbo_trigger ($e);
  93.         }
  94.     }
  95.     
  96.     
  97.     
  98.     /** ACCESSOR METHODS **/
  99.     /**
  100.      * Returns if to include defined PHP Constants
  101.      * @return bool 
  102.      */
  103.     public function getPhp ({
  104.         return $this->_php;
  105.     }
  106.     
  107. }
  108.  
  109. ?>