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

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 2
5.56 %5.56%
5.56% 1 / 18
 
HTMLPurifier_AttrDef_CSS_Length
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 2
5.56 %5.56%
5.56% 1 / 18
 public function __construct($min = NULL, $max = NULL)
0.00 %0.00%
0.00% 0 / 1
100.00 %100.00%
100.00% 0 / 0
 public function validate($string, $config, $context)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 17


       1                 : <?php                                                                                                  
       2                 :                                                                                                        
       3                 : /**                                                                                                    
       4                 :  * Represents a Length as defined by CSS.                                                              
       5                 :  */                                                                                                    
       6               1 : class HTMLPurifier_AttrDef_CSS_Length extends HTMLPurifier_AttrDef                                     
       7                 : {                                                                                                      
       8                 :                                                                                                        
       9                 :     protected $min, $max;                                                                              
      10                 :                                                                                                        
      11                 :     /**                                                                                                
      12                 :      * @param HTMLPurifier_Length $max Minimum length, or null for no bound. String is also acceptable.
      13                 :      * @param HTMLPurifier_Length $max Maximum length, or null for no bound. String is also acceptable.
      14                 :      */                                                                                                
      15                 :     public function __construct($min = null, $max = null) {                                            
      16                 :         $this->min = $min !== null ? HTMLPurifier_Length::make($min) : null;                           
      17                 :         $this->max = $max !== null ? HTMLPurifier_Length::make($max) : null;                           
      18                 :     }                                                                                                  
      19                 :                                                                                                        
      20                 :     public function validate($string, $config, $context) {                                             
      21               0 :         $string = $this->parseCDATA($string);                                                          
      22                 :                                                                                                        
      23                 :         // Optimizations                                                                               
      24               0 :         if ($string === '') return false;                                                              
      25               0 :         if ($string === '0') return '0';                                                               
      26               0 :         if (strlen($string) === 1) return false;                                                       
      27                 :                                                                                                        
      28               0 :         $length = HTMLPurifier_Length::make($string);                                                  
      29               0 :         if (!$length->isValid()) return false;                                                         
      30                 :                                                                                                        
      31               0 :         if ($this->min) {                                                                              
      32               0 :             $c = $length->compareTo($this->min);                                                       
      33               0 :             if ($c === false) return false;                                                            
      34               0 :             if ($c < 0) return false;                                                                  
      35               0 :         }                                                                                              
      36               0 :         if ($this->max) {                                                                              
      37               0 :             $c = $length->compareTo($this->max);                                                       
      38               0 :             if ($c === false) return false;                                                            
      39               0 :             if ($c > 0) return false;                                                                  
      40               0 :         }                                                                                              
      41                 :                                                                                                        
      42               0 :         return $length->toString();                                                                    
      43                 :     }                                                                                                  
      44                 :                                                                                                        
      45                 : }                                                                                                      
      46                 :                                                                                                        

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