Path.php
Current file: /home/nuno/workspace/phmagick/phMagick/Core/Path.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00% 0 / 1
57.14% 4 / 7 CRAP
77.42% 24 / 31
Path
0.00% 0 / 1
57.14% 4 / 7 11.15
77.42% 24 / 31
 __construct($path = null)
100.00% 1 / 1 1
100.00% 2 / 2
 setPath($path)
100.00% 1 / 1 1
100.00% 2 / 2
 getPath()
100.00% 1 / 1 1
100.00% 1 / 1
 format()
0.00% 0 / 1 3.00
93.75% 15 / 16
 __toString()
0.00% 0 / 1 6
0.00% 0 / 4
 up()
0.00% 0 / 1 2
0.00% 0 / 2
 add($item)
100.00% 1 / 1 1
100.00% 4 / 4


       1                 : <?php                                                             
       2                 : namespace phMagick\Core;                                          
       3                 :                                                                   
       4                 : use phMagick\Core\Exception\PathNotFoundException;                
       5                 : class Path                                                        
       6                 : {                                                                 
       7                 :     private $path;                                                
       8                 :     public function __construct($path = null)                     
       9                 :     {                                                             
      10              15 :         $this->setPath($path);                                    
      11              15 :     }                                                             
      12                 :                                                                   
      13                 :     private function setPath($path)                               
      14                 :     {                                                             
      15              15 :         $this->path = $path;                                      
      16              15 :     }                                                             
      17                 :                                                                   
      18                 :     private function getPath()                                    
      19                 :     {                                                             
      20               5 :         return $this->path;                                       
      21                 :     }                                                             
      22                 :                                                                   
      23                 :     function format()                                             
      24                 :     {                                                             
      25                 :                                                                   
      26               4 :         $path = $this->getPath();                                 
      27                 :                                                                   
      28               4 :         $path = str_replace('\\', DIRECTORY_SEPARATOR, $path);    
      29                 :                                                                   
      30                 :                                                                   
      31               4 :         if ( is_dir($path)) {                                     
      32               4 :             $dirname = $path;                                     
      33               4 :             $file    = '';                                        
      34               4 :         } elseif (is_file($path)) {                               
      35               1 :             $dirname = dirname($path);                            
      36               1 :             $file    = basename($path);                           
      37               1 :         } else {                                                  
      38               0 :             throw new PathNotFoundException($path . ' not found');
      39                 :         }                                                         
      40                 :                                                                   
      41                 :                                                                   
      42               4 :         $dirname = rtrim($dirname, DIRECTORY_SEPARATOR);          
      43               4 :         $dirname .= DIRECTORY_SEPARATOR;                          
      44                 :                                                                   
      45                 :                                                                   
      46               4 :         $path = $dirname . $file ;                                
      47                 :                                                                   
      48               4 :         $path = str_replace(' ','\ ',$path) ;                     
      49               4 :         $this->setPath($path);                                    
      50               4 :         return $path;                                             
      51                 :     }                                                             
      52                 :                                                                   
      53                 :     public function __toString()                                  
      54                 :     {                                                             
      55                 :         try {                                                     
      56               0 :             $ret = $this->format();                               
      57               0 :         } Catch (\Exception $e) {                                 
      58               0 :             $ret = '';                                            
      59                 :         }                                                         
      60                 :                                                                   
      61               0 :         return $ret;                                              
      62                 :     }                                                             
      63                 :                                                                   
      64                 :     function up()                                                 
      65                 :     {                                                             
      66               0 :         $this->setPath( dirname($this->getPath()) );              
      67               0 :         return $this;                                             
      68                 :     }                                                             
      69                 :                                                                   
      70                 :     function add($item)                                           
      71                 :     {                                                             
      72               1 :         $this->setPath (                                          
      73               1 :             $this->getPath() . DIRECTORY_SEPARATOR . $item        
      74               1 :         );                                                        
      75               1 :         return $this;                                             
      76                 :     }                                                             

Generated by PHP_CodeCoverage 1.1.1 using PHP 5.3.10 and PHPUnit 3.6.7 at Fri Apr 20 19:24:32 CEST 2012.