PHPIDS
Current file: /home/mario/workspace/php-ids.org/trunk/lib/IDS/vendors/htmlpurifier/HTMLPurifier/AttrDef/Switch.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
20.00 %20.00%
20.00% 1 / 5
 
HTMLPurifier_AttrDef_Switch
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 2
20.00 %20.00%
20.00% 1 / 5
 public function __construct($tag, $with_tag, $without_tag)
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 / 4


       1                 : <?php                                                                                            
       2                 :                                                                                                  
       3                 : /**                                                                                              
       4                 :  * Decorator that, depending on a token, switches between two definitions.                       
       5                 :  */                                                                                              
       6                 : class HTMLPurifier_AttrDef_Switch                                                                
       7               1 : {                                                                                                
       8                 :                                                                                                  
       9                 :     protected $tag;                                                                              
      10                 :     protected $withTag, $withoutTag;                                                             
      11                 :                                                                                                  
      12                 :     /**                                                                                          
      13                 :      * @param string $tag Tag name to switch upon                                                
      14                 :      * @param HTMLPurifier_AttrDef $with_tag Call if token matches tag                           
      15                 :      * @param HTMLPurifier_AttrDef $without_tag Call if token doesn't match, or there is no token
      16                 :      */                                                                                          
      17                 :     public function __construct($tag, $with_tag, $without_tag) {                                 
      18                 :         $this->tag = $tag;                                                                       
      19                 :         $this->withTag = $with_tag;                                                              
      20                 :         $this->withoutTag = $without_tag;                                                        
      21                 :     }                                                                                            
      22                 :                                                                                                  
      23                 :     public function validate($string, $config, $context) {                                       
      24               0 :         $token = $context->get('CurrentToken', true);                                            
      25               0 :         if (!$token || $token->name !== $this->tag) {                                            
      26               0 :             return $this->withoutTag->validate($string, $config, $context);                      
      27                 :         } else {                                                                                 
      28               0 :             return $this->withTag->validate($string, $config, $context);                         
      29                 :         }                                                                                        
      30                 :     }                                                                                            
      31                 :                                                                                                  
      32                 : }                                                                                                

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