[ create a new paste ] login | about

Link: http://codepad.org/cBTxfsye    [ raw code | fork ]

PHP, pasted on Dec 17:
<?php
 
    /**
     * Registry
     * Hold global variables.
     * 
     * @package Downloads Site
     * @author Truth
     * @copyright 2011
     * @version $Id$
     * @access public
     */
    class Registry {
        
        public static $instance;
        /**
         * Registry::getInstance()
         * Allows the use of the Singleton structure
         * 
         * @return
         */
        public static function getInstance() {
            
            if (!is_a(self::$instance, 'Registry')) {
                self::$instance = new Registry();
            }
            return self::$instance;
            
        }
        /**
         * $vars
         * An array of variables
         */
        public $vars = array();
        
        /**
         * Registry::__set()
         * 
         * @param mixed $index
         * @param mixed $value
         * @return void
         */
        public function __set($index, $value) {
            $this->vars[$index] = $value;
        }
        
        /**
         * Registry::__get()
         * 
         * @param mixed $index
         * @return
         */
        public function __get($index) {
            return $this->vars[$index];
        }
        
    }

?>


Create a new paste based on this one


Comments: