Source for file Factory.class.php

Documentation is available at Factory.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 Report Factory Class
  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 Report Factory Class
  30.  * @version 0.0.1
  31.  */
  32.  
  33. gumbo_load ("Interface_Factory");
  34.  
  35. class Gumbo_Debug_Report_Factory implements Gumbo_Interface_Factory {
  36.     
  37.     /**
  38.      * Returns an instantiated object
  39.      * @param string $name name of the class or key string
  40.      * @param mixed $args additional arguments
  41.      * @return StdClass 
  42.      * @throws Gumbo_Exception
  43.      * @uses Gumbo_Load, Gumbo_Debug
  44.      */
  45.     public function factory ($name=null$args=null{
  46.         try {
  47.             // verify precondition
  48.             if (is_null ($name)) {
  49.                 $name "screen";
  50.             }
  51.             if (!is_string ($name)) {
  52.                 throw new Gumbo_Exception ("Invalid Argument 'name:str' => {$name}:getType ($name));
  53.             }
  54.             
  55.             $class_name "Gumbo_Debug_Report_" ucwords ($name);
  56.             if (!Gumbo_Load::instance ()->$class_name{
  57.                 throw new Gumbo_Exception_Class ("Class|Interface Not Found: {$class_name}");
  58.             }
  59.             
  60.             $obj new $class_name ();
  61.             $obj->setMessages (Gumbo_Debug::instance ()->getAllMessages ());
  62.             return $obj;
  63.         catch (Gumbo_Exception $e{
  64.             $e->setFunction (__METHOD__);
  65.             gumbo_trigger ($e);
  66.         }
  67.         return null;
  68.     }
  69.     
  70. }
  71.  
  72. ?>