PHPIDS
Current file: /home/mario/workspace/php-ids.org/trunk/lib/IDS/vendors/htmlpurifier/HTMLPurifier/AttrDef/CSS/Multiple.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
6.25 %6.25%
6.25% 1 / 16
 
HTMLPurifier_AttrDef_CSS_Multiple
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 2
6.25 %6.25%
6.25% 1 / 16
 public function __construct($single, $max = 4)
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 / 15


       1                 : <?php                                                                        
       2                 :                                                                              
       3                 : /**                                                                          
       4                 :  * Framework class for strings that involve multiple values.                 
       5                 :  *                                                                           
       6                 :  * Certain CSS properties such as border-width and margin allow multiple     
       7                 :  * lengths to be specified.  This class can take a vanilla border-width      
       8                 :  * definition and multiply it, usually into a max of four.                   
       9                 :  *                                                                           
      10                 :  * @note Even though the CSS specification isn't clear about it, inherit     
      11                 :  *       can only be used alone: it will never manifest as part of a multi   
      12                 :  *       shorthand declaration.  Thus, this class does not allow inherit.    
      13                 :  */                                                                          
      14               1 : class HTMLPurifier_AttrDef_CSS_Multiple extends HTMLPurifier_AttrDef         
      15                 : {                                                                            
      16                 :                                                                              
      17                 :     /**                                                                      
      18                 :      * Instance of component definition to defer validation to.              
      19                 :      * @todo Make protected                                                  
      20                 :      */                                                                      
      21                 :     public $single;                                                          
      22                 :                                                                              
      23                 :     /**                                                                      
      24                 :      * Max number of values allowed.                                         
      25                 :      * @todo Make protected                                                  
      26                 :      */                                                                      
      27                 :     public $max;                                                             
      28                 :                                                                              
      29                 :     /**                                                                      
      30                 :      * @param $single HTMLPurifier_AttrDef to multiply                       
      31                 :      * @param $max Max number of values allowed (usually four)               
      32                 :      */                                                                      
      33                 :     public function __construct($single, $max = 4) {                         
      34                 :         $this->single = $single;                                             
      35                 :         $this->max = $max;                                                   
      36                 :     }                                                                        
      37                 :                                                                              
      38                 :     public function validate($string, $config, $context) {                   
      39               0 :         $string = $this->parseCDATA($string);                                
      40               0 :         if ($string === '') return false;                                    
      41               0 :         $parts = explode(' ', $string); // parseCDATA replaced \r, \t and \n 
      42               0 :         $length = count($parts);                                             
      43               0 :         $final = '';                                                         
      44               0 :         for ($i = 0, $num = 0; $i < $length && $num < $this->max; $i++) {    
      45               0 :             if (ctype_space($parts[$i])) continue;                           
      46               0 :             $result = $this->single->validate($parts[$i], $config, $context);
      47               0 :             if ($result !== false) {                                         
      48               0 :                 $final .= $result . ' ';                                     
      49               0 :                 $num++;                                                      
      50               0 :             }                                                                
      51               0 :         }                                                                    
      52               0 :         if ($final === '') return false;                                     
      53               0 :         return rtrim($final);                                                
      54                 :     }                                                                        
      55                 :                                                                              
      56                 : }                                                                            
      57                 :                                                                              

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