Current file: htdocs/lib/Zend/Log/Formatter/Simple.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 / 2 CRAP
43.75%43.75%
43.75% 7 / 16
 
Zend_Log_Formatter_Simple
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 2
43.75%43.75%
43.75% 7 / 16
 __construct($format = null)
0.00%0.00%
0.00% 0 / 1 12
0.00%0.00%
0.00% 0 / 7
 format($event)
0.00%0.00%
0.00% 0 / 1 5.27
77.78%77.78%
77.78% 7 / 9


       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 Formatter                                                               
      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: Simple.php 20096 2010-01-06 02:05:09Z bkarwin $                    
      21                 :  */                                                                                    
      22                 :                                                                                        
      23                 : /** Zend_Log_Formatter_Interface */                                                    
      24                 : #require_once 'Zend/Log/Formatter/Interface.php';                                      
      25                 :                                                                                        
      26                 : /**                                                                                    
      27                 :  * @category   Zend                                                                    
      28                 :  * @package    Zend_Log                                                                
      29                 :  * @subpackage Formatter                                                               
      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: Simple.php 20096 2010-01-06 02:05:09Z bkarwin $                    
      33                 :  */                                                                                    
      34                 : class Zend_Log_Formatter_Simple implements Zend_Log_Formatter_Interface                
      35                 : {                                                                                      
      36                 :     /**                                                                                
      37                 :      * @var string                                                                     
      38                 :      */                                                                                
      39                 :     protected $_format;                                                                
      40                 :                                                                                        
      41                 :     const DEFAULT_FORMAT = '%timestamp% %priorityName% (%priority%): %message%';       
      42                 :                                                                                        
      43                 :     /**                                                                                
      44                 :      * Class constructor                                                               
      45                 :      *                                                                                 
      46                 :      * @param  null|string  $format  Format specifier for log messages                 
      47                 :      * @throws Zend_Log_Exception                                                      
      48                 :      */                                                                                
      49                 :     public function __construct($format = null)                                        
      50                 :     {                                                                                  
      51               0 :         if ($format === null) {                                                        
      52               0 :             $format = self::DEFAULT_FORMAT . PHP_EOL;                                  
      53               0 :         }                                                                              
      54                 :                                                                                        
      55               0 :         if (! is_string($format)) {                                                    
      56                 :             #require_once 'Zend/Log/Exception.php';                                    
      57               0 :             throw new Zend_Log_Exception('Format must be a string');                   
      58                 :         }                                                                              
      59                 :                                                                                        
      60               0 :         $this->_format = $format;                                                      
      61               0 :     }                                                                                  
      62                 :                                                                                        
      63                 :     /**                                                                                
      64                 :      * Formats data into a single line to be written by the writer.                    
      65                 :      *                                                                                 
      66                 :      * @param  array    $event    event data                                           
      67                 :      * @return string             formatted line to write to the log                   
      68                 :      */                                                                                
      69                 :     public function format($event)                                                     
      70                 :     {                                                                                  
      71               7 :         $output = $this->_format;                                                      
      72               7 :         foreach ($event as $name => $value) {                                          
      73                 :                                                                                        
      74               7 :             if ((is_object($value) && !method_exists($value,'__toString'))             
      75               7 :                 || is_array($value)) {                                                 
      76                 :                                                                                        
      77               0 :                 $value = gettype($value);                                              
      78               0 :             }                                                                          
      79                 :                                                                                        
      80               7 :             $output = str_replace("%$name%", $value, $output);                         
      81               7 :         }                                                                              
      82               7 :         return $output;                                                                
      83                 :     }                                                                                  
      84                 :                                                                                        
      85                 : }                                                                                      

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.