PHPIDS
Current file: /home/mario/workspace/php-ids.org/trunk/lib/IDS/vendors/htmlpurifier/HTMLPurifier/Context.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
60.00 %60.00%
60.00% 3 / 5
52.17 %52.17%
52.17% 12 / 23
 
HTMLPurifier_Context
100.00 %100.00%
100.00% 1 / 1
60.00 %60.00%
60.00% 3 / 5
52.17 %52.17%
52.17% 12 / 23
 public function register($name, &$ref)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 3 / 3
 public function &get($name, $ignore_error = false)
100.00 %100.00%
100.00% 1 / 1
62.50 %62.50%
62.50% 5 / 8
 public function destroy($name)
100.00 %100.00%
100.00% 1 / 1
50.00 %50.00%
50.00% 3 / 6
 public function exists($name)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function loadArray($context_array)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 4


       1                 : <?php                                                                             
       2                 :                                                                                   
       3                 : /**                                                                               
       4                 :  * Registry object that contains information about the current context.           
       5                 :  * @warning Is a bit buggy when variables are set to null: it thinks              
       6                 :  *          they don't exist! So use false instead, please.                       
       7                 :  * @note Since the variables Context deals with may not be objects,               
       8                 :  *       references are very important here! Do not remove!                       
       9                 :  */                                                                               
      10                 : class HTMLPurifier_Context                                                        
      11               1 : {                                                                                 
      12                 :                                                                                   
      13                 :     /**                                                                           
      14                 :      * Private array that stores the references.                                  
      15                 :      */                                                                           
      16                 :     private $_storage = array();                                                  
      17                 :                                                                                   
      18                 :     /**                                                                           
      19                 :      * Registers a variable into the context.                                     
      20                 :      * @param $name String name                                                   
      21                 :      * @param $ref Reference to variable to be registered                         
      22                 :      */                                                                           
      23                 :     public function register($name, &$ref) {                                      
      24               2 :         if (isset($this->_storage[$name])) {                                      
      25                 :             trigger_error("Name $name produces collision, cannot re-register",    
      26                 :                           E_USER_ERROR);                                          
      27                 :             return;                                                               
      28                 :         }                                                                         
      29               2 :         $this->_storage[$name] =& $ref;                                           
      30               2 :     }                                                                             
      31                 :                                                                                   
      32                 :     /**                                                                           
      33                 :      * Retrieves a variable reference from the context.                           
      34                 :      * @param $name String name                                                   
      35                 :      * @param $ignore_error Boolean whether or not to ignore error                
      36                 :      */                                                                           
      37                 :     public function &get($name, $ignore_error = false) {                          
      38               2 :         if (!isset($this->_storage[$name])) {                                     
      39               2 :             if (!$ignore_error) {                                                 
      40               0 :                 trigger_error("Attempted to retrieve non-existent variable $name",
      41               0 :                               E_USER_ERROR);                                      
      42               0 :             }                                                                     
      43               2 :             $var = null; // so we can return by reference                         
      44               2 :             return $var;                                                          
      45                 :         }                                                                         
      46               2 :         return $this->_storage[$name];                                            
      47                 :     }                                                                             
      48                 :                                                                                   
      49                 :     /**                                                                           
      50                 :      * Destorys a variable in the context.                                        
      51                 :      * @param $name String name                                                   
      52                 :      */                                                                           
      53                 :     public function destroy($name) {                                              
      54               2 :         if (!isset($this->_storage[$name])) {                                     
      55               0 :             trigger_error("Attempted to destroy non-existent variable $name",     
      56               0 :                           E_USER_ERROR);                                          
      57               0 :             return;                                                               
      58                 :         }                                                                         
      59               2 :         unset($this->_storage[$name]);                                            
      60               2 :     }                                                                             
      61                 :                                                                                   
      62                 :     /**                                                                           
      63                 :      * Checks whether or not the variable exists.                                 
      64                 :      * @param $name String name                                                   
      65                 :      */                                                                           
      66                 :     public function exists($name) {                                               
      67               0 :         return isset($this->_storage[$name]);                                     
      68                 :     }                                                                             
      69                 :                                                                                   
      70                 :     /**                                                                           
      71                 :      * Loads a series of variables from an associative array                      
      72                 :      * @param $context_array Assoc array of variables to load                     
      73                 :      */                                                                           
      74                 :     public function loadArray($context_array) {                                   
      75               0 :         foreach ($context_array as $key => $discard) {                            
      76               0 :             $this->register($key, $context_array[$key]);                          
      77               0 :         }                                                                         
      78               0 :     }                                                                             
      79                 :                                                                                   
      80                 : }                                                                                 
      81                 :                                                                                   

Generated by PHPUnit 3.3.1 and Xdebug 2.0.2 at Thu Sep 25 18:42:10 CEST 2008.