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

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 3 / 3
80.00 %80.00%
80.00% 8 / 10
 
HTMLPurifier_IDAccumulator
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 3 / 3
80.00 %80.00%
80.00% 8 / 10
 public static function build($config, $context)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 3 / 3
 public function add($id)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 2 / 2
 public function load($array_of_ids)
100.00 %100.00%
100.00% 1 / 1
50.00 %50.00%
50.00% 2 / 4


       1                 : <?php                                                                             
       2                 :                                                                                   
       3                 : /**                                                                               
       4                 :  * Component of HTMLPurifier_AttrContext that accumulates IDs to prevent dupes    
       5                 :  * @note In Slashdot-speak, dupe means duplicate.                                 
       6                 :  * @note The default constructor does not accept $config or $context objects:     
       7                 :  *       use must use the static build() factory method to perform initialization.
       8                 :  */                                                                               
       9                 : class HTMLPurifier_IDAccumulator                                                  
      10               1 : {                                                                                 
      11                 :                                                                                   
      12                 :     /**                                                                           
      13                 :      * Lookup table of IDs we've accumulated.                                     
      14                 :      * @public                                                                    
      15                 :      */                                                                           
      16                 :     public $ids = array();                                                        
      17                 :                                                                                   
      18                 :     /**                                                                           
      19                 :      * Builds an IDAccumulator, also initializing the default blacklist           
      20                 :      * @param $config Instance of HTMLPurifier_Config                             
      21                 :      * @param $context Instance of HTMLPurifier_Context                           
      22                 :      * @return Fully initialized HTMLPurifier_IDAccumulator                       
      23                 :      */                                                                           
      24                 :     public static function build($config, $context) {                             
      25               2 :         $id_accumulator = new HTMLPurifier_IDAccumulator();                       
      26               2 :         $id_accumulator->load($config->get('Attr', 'IDBlacklist'));               
      27               2 :         return $id_accumulator;                                                   
      28                 :     }                                                                             
      29                 :                                                                                   
      30                 :     /**                                                                           
      31                 :      * Add an ID to the lookup table.                                             
      32                 :      * @param $id ID to be added.                                                 
      33                 :      * @return Bool status, true if success, false if there's a dupe              
      34                 :      */                                                                           
      35                 :     public function add($id) {                                                    
      36               1 :         if (isset($this->ids[$id])) return false;                                 
      37               1 :         return $this->ids[$id] = true;                                            
      38                 :     }                                                                             
      39                 :                                                                                   
      40                 :     /**                                                                           
      41                 :      * Load a list of IDs into the lookup table                                   
      42                 :      * @param $array_of_ids Array of IDs to load                                  
      43                 :      * @note This function doesn't care about duplicates                          
      44                 :      */                                                                           
      45                 :     public function load($array_of_ids) {                                         
      46               2 :         foreach ($array_of_ids as $id) {                                          
      47               0 :             $this->ids[$id] = true;                                               
      48               0 :         }                                                                         
      49               2 :     }                                                                             
      50                 :                                                                                   
      51                 : }                                                                                 
      52                 :                                                                                   

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