LoggerThrowableInformation.php
Current file: /home/ihabunek/apache/log4php/src/main/php/LoggerThrowableInformation.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
100.00% 1 / 1
100.00% 3 / 3 CRAP
100.00% 11 / 11
LoggerThrowableInformation
100.00% 1 / 1
100.00% 3 / 3 5
100.00% 11 / 11
 __construct(Exception $throwable)
100.00% 1 / 1 1
100.00% 2 / 2
 getThrowable()
100.00% 1 / 1 1
100.00% 1 / 1
 getStringRepresentation()
100.00% 1 / 1 3
100.00% 8 / 8


       1                 : <?php                                                                                                         
       2                 : /**                                                                                                           
       3                 :  * Licensed to the Apache Software Foundation (ASF) under one or more                                         
       4                 :  * contributor license agreements. See the NOTICE file distributed with                                       
       5                 :  * this work for additional information regarding copyright ownership.                                        
       6                 :  * The ASF licenses this file to You under the Apache License, Version 2.0                                    
       7                 :  * (the "License"); you may not use this file except in compliance with                                       
       8                 :  * the License. You may obtain a copy of the License at                                                       
       9                 :  *                                                                                                            
      10                 :  *       http://www.apache.org/licenses/LICENSE-2.0                                                           
      11                 :  *                                                                                                            
      12                 :  * Unless required by applicable law or agreed to in writing, software                                        
      13                 :  * distributed under the License is distributed on an "AS IS" BASIS,                                          
      14                 :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.                                   
      15                 :  * See the License for the specific language governing permissions and                                        
      16                 :  * limitations under the License.                                                                             
      17                 :  *                                                                                                            
      18                 :  * @package log4php                                                                                           
      19                 :  */                                                                                                           
      20                 :                                                                                                               
      21                 : /**                                                                                                           
      22                 :  * The internal representation of throwables.                                                                 
      23                 :  *                                                                                                            
      24                 :  * @package log4php                                                                                           
      25                 :  * @since 2.1                                                                                                 
      26                 :  */                                                                                                           
      27                 : class LoggerThrowableInformation {                                                                            
      28                 :                                                                                                               
      29                 :     /** @var Exception Throwable to log */                                                                    
      30                 :     private $throwable;                                                                                       
      31                 :                                                                                                               
      32                 :     /** @var array Array of throwable messages */                                                             
      33                 :     private $throwableArray;                                                                                  
      34                 :                                                                                                               
      35                 :     /** @var Logger reference */                                                                              
      36                 :     private $logger;                                                                                          
      37                 :                                                                                                               
      38                 :     /**                                                                                                       
      39                 :      * Create a new instance                                                                                  
      40                 :      *                                                                                                        
      41                 :      * @param $throwable - a throwable as a exception                                                         
      42                 :      * @param $logger - Logger reference                                                                      
      43                 :      */                                                                                                       
      44                 :     public function __construct(Exception $throwable)  {                                                      
      45               6 :         $this->throwable = $throwable;                                                                        
      46               6 :     }                                                                                                         
      47                 :                                                                                                               
      48                 :     /**                                                                                                       
      49                 :     * Return source exception                                                                                 
      50                 :     *                                                                                                         
      51                 :     * @return Exception                                                                                       
      52                 :     */                                                                                                        
      53                 :     public function getThrowable() {                                                                          
      54               3 :         return $this->throwable;                                                                              
      55                 :     }                                                                                                         
      56                 :                                                                                                               
      57                 :     /**                                                                                                       
      58                 :      * @desc Returns string representation of throwable                                                       
      59                 :      *                                                                                                        
      60                 :      * @return array                                                                                          
      61                 :      */                                                                                                       
      62                 :     public function getStringRepresentation() {                                                               
      63               3 :         if (!is_array($this->throwableArray)) {                                                               
      64               3 :             $renderer = Logger::getHierarchy()->getRendererMap()->getByClassName(get_class($this->throwable));
      65                 :                                                                                                               
      66                 :             // TODO: why this?                                                                                
      67               3 :             if ($renderer instanceof LoggerRendererDefault) {                                                 
      68               3 :                 $renderer = new LoggerRendererException();                                                    
      69               3 :             }                                                                                                 
      70               3 :             $this->throwableArray = explode("\n", $renderer->render($this->throwable));                       
      71               3 :         }                                                                                                     
      72                 :                                                                                                               
      73               3 :         return $this->throwableArray;                                                                         
      74                 :     }                                                                                                         
      75                 : }                                                                                                             

Generated by PHP_CodeCoverage 1.1.1 using PHP 5.3.3-7+squeeze3 and PHPUnit 3.6.3 at Sat Feb 18 22:32:39 GMT 2012.