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

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
50.00 %50.00%
50.00% 1 / 2
38.46 %38.46%
38.46% 5 / 13
 
HTMLPurifier_AttrTransform_EnumToCSS
100.00 %100.00%
100.00% 1 / 1
50.00 %50.00%
50.00% 1 / 2
38.46 %38.46%
38.46% 5 / 13
 public function __construct($attr, $enum_to_css, $case_sensitive = false)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 4 / 4
 public function transform($attr, $config, $context)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 8


       1                 : <?php                                                                          
       2                 :                                                                                
       3                 : /**                                                                            
       4                 :  * Generic pre-transform that converts an attribute with a fixed number of     
       5                 :  * values (enumerated) to CSS.                                                 
       6                 :  */                                                                            
       7               1 : class HTMLPurifier_AttrTransform_EnumToCSS extends HTMLPurifier_AttrTransform {
       8                 :                                                                                
       9                 :     /**                                                                        
      10                 :      * Name of attribute to transform from                                     
      11                 :      */                                                                        
      12                 :     protected $attr;                                                           
      13                 :                                                                                
      14                 :     /**                                                                        
      15                 :      * Lookup array of attribute values to CSS                                 
      16                 :      */                                                                        
      17                 :     protected $enumToCSS = array();                                            
      18                 :                                                                                
      19                 :     /**                                                                        
      20                 :      * Case sensitivity of the matching                                        
      21                 :      * @warning Currently can only be guaranteed to work with ASCII            
      22                 :      *          values.                                                        
      23                 :      */                                                                        
      24                 :     protected $caseSensitive = false;                                          
      25                 :                                                                                
      26                 :     /**                                                                        
      27                 :      * @param $attr String attribute name to transform from                    
      28                 :      * @param $enumToCSS Lookup array of attribute values to CSS               
      29                 :      * @param $case_sensitive Boolean case sensitivity indicator, default false
      30                 :      */                                                                        
      31                 :     public function __construct($attr, $enum_to_css, $case_sensitive = false) {
      32               1 :         $this->attr = $attr;                                                   
      33               1 :         $this->enumToCSS = $enum_to_css;                                       
      34               1 :         $this->caseSensitive = (bool) $case_sensitive;                         
      35               1 :     }                                                                          
      36                 :                                                                                
      37                 :     public function transform($attr, $config, $context) {                      
      38                 :                                                                                
      39               0 :         if (!isset($attr[$this->attr])) return $attr;                          
      40                 :                                                                                
      41               0 :         $value = trim($attr[$this->attr]);                                     
      42               0 :         unset($attr[$this->attr]);                                             
      43                 :                                                                                
      44               0 :         if (!$this->caseSensitive) $value = strtolower($value);                
      45                 :                                                                                
      46               0 :         if (!isset($this->enumToCSS[$value])) {                                
      47               0 :             return $attr;                                                      
      48                 :         }                                                                      
      49                 :                                                                                
      50               0 :         $this->prependCSS($attr, $this->enumToCSS[$value]);                    
      51                 :                                                                                
      52               0 :         return $attr;                                                          
      53                 :                                                                                
      54                 :     }                                                                          
      55                 :                                                                                
      56                 : }                                                                              
      57                 :                                                                                

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