Current file: htdocs/lib/Zend/Log/Writer/Abstract.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 5 CRAP
17.39%17.39%
17.39% 4 / 23
 
Zend_Log_Writer_Abstract
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 5
17.39%17.39%
17.39% 4 / 23
 addFilter($filter)
0.00%0.00%
0.00% 0 / 1 12
0.00%0.00%
0.00% 0 / 7
 write($event)
0.00%0.00%
0.00% 0 / 1 3.33
66.67%66.67%
66.67% 4 / 6
 setFormatter(Zend_Log_Formatter_Interface $formatter)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2
 shutdown()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 _parseConfig($config)
0.00%0.00%
0.00% 0 / 1 12
0.00%0.00%
0.00% 0 / 7


       1                 : <?php                                                                                  
       2                 : /**                                                                                    
       3                 :  * Zend Framework                                                                      
       4                 :  *                                                                                     
       5                 :  * LICENSE                                                                             
       6                 :  *                                                                                     
       7                 :  * This source file is subject to the new BSD license that is bundled                  
       8                 :  * with this package in the file LICENSE.txt.                                          
       9                 :  * It is also available through the world-wide-web at this URL:                        
      10                 :  * http://framework.zend.com/license/new-bsd                                           
      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@zend.com so we can send you a copy immediately.                          
      14                 :  *                                                                                     
      15                 :  * @category   Zend                                                                    
      16                 :  * @package    Zend_Log                                                                
      17                 :  * @subpackage Writer                                                                  
      18                 :  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
      19                 :  * @license    http://framework.zend.com/license/new-bsd     New BSD License           
      20                 :  * @version    $Id: Abstract.php 22567 2010-07-16 03:32:31Z ramon $                    
      21                 :  */                                                                                    
      22                 :                                                                                        
      23                 : /** Zend_Log_Filter_Priority */                                                        
      24                 : #require_once 'Zend/Log/Filter/Priority.php';                                          
      25                 :                                                                                        
      26                 : /**                                                                                    
      27                 :  * @category   Zend                                                                    
      28                 :  * @package    Zend_Log                                                                
      29                 :  * @subpackage Writer                                                                  
      30                 :  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
      31                 :  * @license    http://framework.zend.com/license/new-bsd     New BSD License           
      32                 :  * @version    $Id: Abstract.php 22567 2010-07-16 03:32:31Z ramon $                    
      33                 :  */                                                                                    
      34                 : abstract class Zend_Log_Writer_Abstract implements Zend_Log_FactoryInterface           
      35                 : {                                                                                      
      36                 :     /**                                                                                
      37                 :      * @var array of Zend_Log_Filter_Interface                                         
      38                 :      */                                                                                
      39                 :     protected $_filters = array();                                                     
      40                 :                                                                                        
      41                 :     /**                                                                                
      42                 :      * Formats the log message before writing.                                         
      43                 :      * @var Zend_Log_Formatter_Interface                                               
      44                 :      */                                                                                
      45                 :     protected $_formatter;                                                             
      46                 :                                                                                        
      47                 :     /**                                                                                
      48                 :      * Add a filter specific to this writer.                                           
      49                 :      *                                                                                 
      50                 :      * @param  Zend_Log_Filter_Interface  $filter                                      
      51                 :      * @return void                                                                    
      52                 :      */                                                                                
      53                 :     public function addFilter($filter)                                                 
      54                 :     {                                                                                  
      55               0 :         if (is_integer($filter)) {                                                     
      56               0 :             $filter = new Zend_Log_Filter_Priority($filter);                           
      57               0 :         }                                                                              
      58                 :                                                                                        
      59               0 :         if (!$filter instanceof Zend_Log_Filter_Interface) {                           
      60                 :             /** @see Zend_Log_Exception */                                             
      61                 :             #require_once 'Zend/Log/Exception.php';                                    
      62               0 :             throw new Zend_Log_Exception('Invalid filter provided');                   
      63                 :         }                                                                              
      64                 :                                                                                        
      65               0 :         $this->_filters[] = $filter;                                                   
      66               0 :         return $this;                                                                  
      67                 :     }                                                                                  
      68                 :                                                                                        
      69                 :     /**                                                                                
      70                 :      * Log a message to this writer.                                                   
      71                 :      *                                                                                 
      72                 :      * @param  array     $event  log data event                                        
      73                 :      * @return void                                                                    
      74                 :      */                                                                                
      75                 :     public function write($event)                                                      
      76                 :     {                                                                                  
      77               7 :         foreach ($this->_filters as $filter) {                                         
      78               0 :             if (! $filter->accept($event)) {                                           
      79               0 :                 return;                                                                
      80                 :             }                                                                          
      81               7 :         }                                                                              
      82                 :                                                                                        
      83                 :         // exception occurs on error                                                   
      84               7 :         $this->_write($event);                                                         
      85               7 :     }                                                                                  
      86                 :                                                                                        
      87                 :     /**                                                                                
      88                 :      * Set a new formatter for this writer                                             
      89                 :      *                                                                                 
      90                 :      * @param  Zend_Log_Formatter_Interface $formatter                                 
      91                 :      * @return void                                                                    
      92                 :      */                                                                                
      93                 :     public function setFormatter(Zend_Log_Formatter_Interface $formatter)              
      94                 :     {                                                                                  
      95               0 :         $this->_formatter = $formatter;                                                
      96               0 :         return $this;                                                                  
      97                 :     }                                                                                  
      98                 :                                                                                        
      99                 :     /**                                                                                
     100                 :      * Perform shutdown activites such as closing open resources                       
     101                 :      *                                                                                 
     102                 :      * @return void                                                                    
     103                 :      */                                                                                
     104                 :     public function shutdown()                                                         
     105               0 :     {}                                                                                 
     106                 :                                                                                        
     107                 :     /**                                                                                
     108                 :      * Write a message to the log.                                                     
     109                 :      *                                                                                 
     110                 :      * @param  array  $event  log data event                                           
     111                 :      * @return void                                                                    
     112                 :      */                                                                                
     113                 :     abstract protected function _write($event);                                        
     114                 :                                                                                        
     115                 :     /**                                                                                
     116                 :      * Validate and optionally convert the config to array                             
     117                 :      *                                                                                 
     118                 :      * @param  array|Zend_Config $config Zend_Config or Array                          
     119                 :      * @return array                                                                   
     120                 :      * @throws Zend_Log_Exception                                                      
     121                 :      */                                                                                
     122                 :     static protected function _parseConfig($config)                                    
     123                 :     {                                                                                  
     124               0 :         if ($config instanceof Zend_Config) {                                          
     125               0 :             $config = $config->toArray();                                              
     126               0 :         }                                                                              
     127                 :                                                                                        
     128               0 :         if (!is_array($config)) {                                                      
     129                 :             #require_once 'Zend/Log/Exception.php';                                    
     130               0 :             throw new Zend_Log_Exception(                                              
     131                 :                 'Configuration must be an array or instance of Zend_Config'            
     132               0 :             );                                                                         
     133                 :         }                                                                              
     134                 :                                                                                        
     135               0 :         return $config;                                                                
     136                 :     }                                                                                  
     137                 : }                                                                                      

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.