PHPIDS
Current file: /home/mario/workspace/php-ids.org/trunk/lib/IDS/vendors/htmlpurifier/HTMLPurifier/AttrDef/HTML/MultiLength.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 / 1
6.25 %6.25%
6.25% 1 / 16
 
HTMLPurifier_AttrDef_HTML_MultiLength
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 1
6.25 %6.25%
6.25% 1 / 16
 public function validate($string, $config, $context)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 15


       1                 : <?php                                                                               
       2                 :                                                                                     
       3                 : /**                                                                                 
       4                 :  * Validates a MultiLength as defined by the HTML spec.                             
       5                 :  *                                                                                  
       6                 :  * A multilength is either a integer (pixel count), a percentage, or                
       7                 :  * a relative number.                                                               
       8                 :  */                                                                                 
       9               1 : class HTMLPurifier_AttrDef_HTML_MultiLength extends HTMLPurifier_AttrDef_HTML_Length
      10                 : {                                                                                   
      11                 :                                                                                     
      12                 :     public function validate($string, $config, $context) {                          
      13                 :                                                                                     
      14               0 :         $string = trim($string);                                                    
      15               0 :         if ($string === '') return false;                                           
      16                 :                                                                                     
      17               0 :         $parent_result = parent::validate($string, $config, $context);              
      18               0 :         if ($parent_result !== false) return $parent_result;                        
      19                 :                                                                                     
      20               0 :         $length = strlen($string);                                                  
      21               0 :         $last_char = $string[$length - 1];                                          
      22                 :                                                                                     
      23               0 :         if ($last_char !== '*') return false;                                       
      24                 :                                                                                     
      25               0 :         $int = substr($string, 0, $length - 1);                                     
      26                 :                                                                                     
      27               0 :         if ($int == '') return '*';                                                 
      28               0 :         if (!is_numeric($int)) return false;                                        
      29                 :                                                                                     
      30               0 :         $int = (int) $int;                                                          
      31                 :                                                                                     
      32               0 :         if ($int < 0) return false;                                                 
      33               0 :         if ($int == 0) return '0';                                                  
      34               0 :         if ($int == 1) return '*';                                                  
      35               0 :         return ((string) $int) . '*';                                               
      36                 :                                                                                     
      37                 :     }                                                                               
      38                 :                                                                                     
      39                 : }                                                                                   
      40                 :                                                                                     

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