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

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
66.67 %66.67%
66.67% 2 / 3
83.33 %83.33%
83.33% 20 / 24
 
HTMLPurifier_AttrTypes
100.00 %100.00%
100.00% 1 / 1
66.67 %66.67%
66.67% 2 / 3
83.33 %83.33%
83.33% 20 / 24
 public function __construct()
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 15 / 15
 public function get($type)
100.00 %100.00%
100.00% 1 / 1
66.67 %66.67%
66.67% 4 / 6
 public function set($type, $impl)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2


       1                 : <?php                                                                                        
       2                 :                                                                                              
       3                 : /**                                                                                          
       4                 :  * Provides lookup array of attribute types to HTMLPurifier_AttrDef objects                  
       5                 :  */                                                                                          
       6                 : class HTMLPurifier_AttrTypes                                                                 
       7               1 : {                                                                                            
       8                 :     /**                                                                                      
       9                 :      * Lookup array of attribute string identifiers to concrete implementations              
      10                 :      */                                                                                      
      11                 :     protected $info = array();                                                               
      12                 :                                                                                              
      13                 :     /**                                                                                      
      14                 :      * Constructs the info array, supplying default implementations for attribute            
      15                 :      * types.                                                                                
      16                 :      */                                                                                      
      17                 :     public function __construct() {                                                          
      18                 :         // pseudo-types, must be instantiated via shorthand                                  
      19               1 :         $this->info['Enum']    = new HTMLPurifier_AttrDef_Enum();                            
      20               1 :         $this->info['Bool']    = new HTMLPurifier_AttrDef_HTML_Bool();                       
      21                 :                                                                                              
      22               1 :         $this->info['CDATA']    = new HTMLPurifier_AttrDef_Text();                           
      23               1 :         $this->info['ID']       = new HTMLPurifier_AttrDef_HTML_ID();                        
      24               1 :         $this->info['Length']   = new HTMLPurifier_AttrDef_HTML_Length();                    
      25               1 :         $this->info['MultiLength'] = new HTMLPurifier_AttrDef_HTML_MultiLength();            
      26               1 :         $this->info['NMTOKENS'] = new HTMLPurifier_AttrDef_HTML_Nmtokens();                  
      27               1 :         $this->info['Pixels']   = new HTMLPurifier_AttrDef_HTML_Pixels();                    
      28               1 :         $this->info['Text']     = new HTMLPurifier_AttrDef_Text();                           
      29               1 :         $this->info['URI']      = new HTMLPurifier_AttrDef_URI();                            
      30               1 :         $this->info['LanguageCode'] = new HTMLPurifier_AttrDef_Lang();                       
      31               1 :         $this->info['Color']    = new HTMLPurifier_AttrDef_HTML_Color();                     
      32                 :                                                                                              
      33                 :         // unimplemented aliases                                                             
      34               1 :         $this->info['ContentType'] = new HTMLPurifier_AttrDef_Text();                        
      35                 :                                                                                              
      36                 :         // number is really a positive integer (one or more digits)                          
      37                 :         // FIXME: ^^ not always, see start and value of list items                           
      38               1 :         $this->info['Number']   = new HTMLPurifier_AttrDef_Integer(false, false, true);      
      39               1 :     }                                                                                        
      40                 :                                                                                              
      41                 :     /**                                                                                      
      42                 :      * Retrieves a type                                                                      
      43                 :      * @param $type String type name                                                         
      44                 :      * @return Object AttrDef for type                                                       
      45                 :      */                                                                                      
      46                 :     public function get($type) {                                                             
      47                 :                                                                                              
      48                 :         // determine if there is any extra info tacked on                                    
      49               1 :         if (strpos($type, '#') !== false) list($type, $string) = explode('#', $type, 2);     
      50               1 :         else $string = '';                                                                   
      51                 :                                                                                              
      52               1 :         if (!isset($this->info[$type])) {                                                    
      53               0 :             trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR);
      54               0 :             return;                                                                          
      55                 :         }                                                                                    
      56                 :                                                                                              
      57               1 :         return $this->info[$type]->make($string);                                            
      58                 :                                                                                              
      59                 :     }                                                                                        
      60                 :                                                                                              
      61                 :     /**                                                                                      
      62                 :      * Sets a new implementation for a type                                                  
      63                 :      * @param $type String type name                                                         
      64                 :      * @param $impl Object AttrDef for type                                                  
      65                 :      */                                                                                      
      66                 :     public function set($type, $impl) {                                                      
      67               0 :         $this->info[$type] = $impl;                                                          
      68               0 :     }                                                                                        
      69                 : }                                                                                            
      70                 :                                                                                              
      71                 :                                                                                              

Generated by PHPUnit 3.2.20 and Xdebug 2.0.3 at Sat Jun 7 16:15:42 CEST 2008.