Current file: htdocs/lib/Varien/Cache/Core.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00%0.00%
0.00% 0 / 1
66.67%66.67%
66.67% 4 / 6 CRAP
78.95%78.95%
78.95% 15 / 19
 
Varien_Cache_Core
0.00%0.00%
0.00% 0 / 1
66.67%66.67%
66.67% 4 / 6
78.95%78.95%
78.95% 15 / 19
 _id($id)
100.00%100.00%
100.00% 1 / 1 3
100.00%100.00%
100.00% 7 / 7
 _tags($tags)
100.00%100.00%
100.00% 1 / 1 2
100.00%100.00%
100.00% 4 / 4
 save($data, $id = null, $tags = array()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 2 / 2
 clean($mode = 'all', $tags = array()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 2 / 2
 getIdsMatchingTags($tags = array()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2
 getIdsNotMatchingTags($tags = array()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2


       1                 : <?php                                                                                                                                  
       2                 : /**                                                                                                                                    
       3                 :  * Magento                                                                                                                             
       4                 :  *                                                                                                                                     
       5                 :  * NOTICE OF LICENSE                                                                                                                   
       6                 :  *                                                                                                                                     
       7                 :  * This source file is subject to the Open Software License (OSL 3.0)                                                                  
       8                 :  * that is bundled with this package in the file LICENSE.txt.                                                                          
       9                 :  * It is also available through the world-wide-web at this URL:                                                                        
      10                 :  * http://opensource.org/licenses/osl-3.0.php                                                                                          
      11                 :  * If you did not receive a copy of the license and are unable to                                                                      
      12                 :  * obtain it through the world-wide-web, please send an email                                                                          
      13                 :  * to license@magentocommerce.com so we can send you a copy immediately.                                                               
      14                 :  *                                                                                                                                     
      15                 :  * DISCLAIMER                                                                                                                          
      16                 :  *                                                                                                                                     
      17                 :  * Do not edit or add to this file if you wish to upgrade Magento to newer                                                             
      18                 :  * versions in the future. If you wish to customize Magento for your                                                                   
      19                 :  * needs please refer to http://www.magentocommerce.com for more information.                                                          
      20                 :  *                                                                                                                                     
      21                 :  * @category   Varien                                                                                                                  
      22                 :  * @package    Varien_Cache                                                                                                            
      23                 :  * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)                                            
      24                 :  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)                                             
      25                 :  */                                                                                                                                    
      26                 :                                                                                                                                        
      27                 : class Varien_Cache_Core extends Zend_Cache_Core                                                                                        
      28                 : {                                                                                                                                      
      29                 :     /**                                                                                                                                
      30                 :      * Make and return a cache id                                                                                                      
      31                 :      *                                                                                                                                 
      32                 :      * Checks 'cache_id_prefix' and returns new id with prefix or simply the id if null                                                
      33                 :      *                                                                                                                                 
      34                 :      * @param  string $id Cache id                                                                                                     
      35                 :      * @return string Cache id (with or without prefix)                                                                                
      36                 :      */                                                                                                                                
      37                 :     protected function _id($id)                                                                                                        
      38                 :     {                                                                                                                                  
      39               2 :         if ($id !== null) {                                                                                                            
      40               2 :             $id = preg_replace('/([^a-zA-Z0-9_]{1,1})/', '_', $id);                                                                    
      41               2 :             if (isset($this->_options['cache_id_prefix'])) {                                                                           
      42               2 :                 $id = $this->_options['cache_id_prefix'] . $id;                                                                        
      43               2 :             }                                                                                                                          
      44               2 :         }                                                                                                                              
      45               2 :         return $id;                                                                                                                    
      46                 :     }                                                                                                                                  
      47                 :                                                                                                                                        
      48                 :     /**                                                                                                                                
      49                 :      * Prepare tags                                                                                                                    
      50                 :      *                                                                                                                                 
      51                 :      * @param array $tags                                                                                                              
      52                 :      * @return array                                                                                                                   
      53                 :      */                                                                                                                                
      54                 :     protected function _tags($tags)                                                                                                    
      55                 :     {                                                                                                                                  
      56               3 :         foreach ($tags as $key=>$tag) {                                                                                                
      57               2 :             $tags[$key] = $this->_id($tag);                                                                                            
      58               3 :         }                                                                                                                              
      59               3 :         return $tags;                                                                                                                  
      60                 :     }                                                                                                                                  
      61                 :                                                                                                                                        
      62                 :     /**                                                                                                                                
      63                 :      * Save some data in a cache                                                                                                       
      64                 :      *                                                                                                                                 
      65                 :      * @param  mixed $data           Data to put in cache (can be another type than string if automatic_serialization is on)           
      66                 :      * @param  string $id             Cache id (if not set, the last cache id will be used)                                            
      67                 :      * @param  array $tags           Cache tags                                                                                        
      68                 :      * @param  int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)            
      69                 :      * @param  int   $priority         integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
      70                 :      * @throws Zend_Cache_Exception                                                                                                    
      71                 :      * @return boolean True if no problem                                                                                              
      72                 :      */                                                                                                                                
      73                 :     public function save($data, $id = null, $tags = array(), $specificLifetime = false, $priority = 8)                                 
      74                 :     {                                                                                                                                  
      75               2 :         $tags = $this->_tags($tags);                                                                                                   
      76               2 :         return parent::save($data, $id, $tags, $specificLifetime, $priority);                                                          
      77                 :     }                                                                                                                                  
      78                 :                                                                                                                                        
      79                 :     /**                                                                                                                                
      80                 :      * Clean cache entries                                                                                                             
      81                 :      *                                                                                                                                 
      82                 :      * Available modes are :                                                                                                           
      83                 :      * 'all' (default)  => remove all cache entries ($tags is not used)                                                                
      84                 :      * 'old'            => remove too old cache entries ($tags is not used)                                                            
      85                 :      * 'matchingTag'    => remove cache entries matching all given tags                                                                
      86                 :      *                     ($tags can be an array of strings or a single string)                                                       
      87                 :      * 'notMatchingTag' => remove cache entries not matching one of the given tags                                                     
      88                 :      *                     ($tags can be an array of strings or a single string)                                                       
      89                 :      * 'matchingAnyTag' => remove cache entries matching any given tags                                                                
      90                 :      *                     ($tags can be an array of strings or a single string)                                                       
      91                 :      *                                                                                                                                 
      92                 :      * @param  string       $mode                                                                                                      
      93                 :      * @param  array|string $tags                                                                                                      
      94                 :      * @throws Zend_Cache_Exception                                                                                                    
      95                 :      * @return boolean True if ok                                                                                                      
      96                 :      */                                                                                                                                
      97                 :     public function clean($mode = 'all', $tags = array())                                                                              
      98                 :     {                                                                                                                                  
      99               1 :         $tags = $this->_tags($tags);                                                                                                   
     100               1 :         return parent::clean($mode, $tags);                                                                                            
     101                 :     }                                                                                                                                  
     102                 :                                                                                                                                        
     103                 :     /**                                                                                                                                
     104                 :      * Return an array of stored cache ids which match given tags                                                                      
     105                 :      *                                                                                                                                 
     106                 :      * In case of multiple tags, a logical AND is made between tags                                                                    
     107                 :      *                                                                                                                                 
     108                 :      * @param array $tags array of tags                                                                                                
     109                 :      * @return array array of matching cache ids (string)                                                                              
     110                 :      */                                                                                                                                
     111                 :     public function getIdsMatchingTags($tags = array())                                                                                
     112                 :     {                                                                                                                                  
     113               0 :         $tags = $this->_tags($tags);                                                                                                   
     114               0 :         return parent::getIdsMatchingTags($tags);                                                                                      
     115                 :     }                                                                                                                                  
     116                 :                                                                                                                                        
     117                 :     /**                                                                                                                                
     118                 :      * Return an array of stored cache ids which don't match given tags                                                                
     119                 :      *                                                                                                                                 
     120                 :      * In case of multiple tags, a logical OR is made between tags                                                                     
     121                 :      *                                                                                                                                 
     122                 :      * @param array $tags array of tags                                                                                                
     123                 :      * @return array array of not matching cache ids (string)                                                                          
     124                 :      */                                                                                                                                
     125                 :     public function getIdsNotMatchingTags($tags = array())                                                                             
     126                 :     {                                                                                                                                  
     127               0 :         $tags = $this->_tags($tags);                                                                                                   
     128               0 :         return parent::getIdsNotMatchingTags($tags);                                                                                   
     129                 :     }                                                                                                                                  

Generated by PHP_CodeCoverage 1.0.4 using PHP 5.3.4 and PHPUnit 3.5.13 at Tue Jul 5 9:07:16 UTC 2011.