PHPIDS
Current file: /home/mario/workspace/php-ids.org/trunk/lib/IDS/vendors/htmlpurifier/HTMLPurifier/AttrDef/CSS/Percentage.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
10.00 %10.00%
10.00% 1 / 10
 
HTMLPurifier_AttrDef_CSS_Percentage
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 2
10.00 %10.00%
10.00% 1 / 10
 public function __construct($non_negative = false)
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 / 9


       1                 : <?php                                                                          
       2                 :                                                                                
       3                 : /**                                                                            
       4                 :  * Validates a Percentage as defined by the CSS spec.                          
       5                 :  */                                                                            
       6               1 : class HTMLPurifier_AttrDef_CSS_Percentage extends HTMLPurifier_AttrDef         
       7                 : {                                                                              
       8                 :                                                                                
       9                 :     /**                                                                        
      10                 :      * Instance of HTMLPurifier_AttrDef_CSS_Number to defer number validation  
      11                 :      */                                                                        
      12                 :     protected $number_def;                                                     
      13                 :                                                                                
      14                 :     /**                                                                        
      15                 :      * @param Bool indicating whether to forbid negative values                
      16                 :      */                                                                        
      17                 :     public function __construct($non_negative = false) {                       
      18                 :         $this->number_def = new HTMLPurifier_AttrDef_CSS_Number($non_negative);
      19                 :     }                                                                          
      20                 :                                                                                
      21                 :     public function validate($string, $config, $context) {                     
      22                 :                                                                                
      23               0 :         $string = $this->parseCDATA($string);                                  
      24                 :                                                                                
      25               0 :         if ($string === '') return false;                                      
      26               0 :         $length = strlen($string);                                             
      27               0 :         if ($length === 1) return false;                                       
      28               0 :         if ($string[$length - 1] !== '%') return false;                        
      29                 :                                                                                
      30               0 :         $number = substr($string, 0, $length - 1);                             
      31               0 :         $number = $this->number_def->validate($number, $config, $context);     
      32                 :                                                                                
      33               0 :         if ($number === false) return false;                                   
      34               0 :         return "$number%";                                                     
      35                 :                                                                                
      36                 :     }                                                                          
      37                 :                                                                                
      38                 : }                                                                              
      39                 :                                                                                

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