CodeReflectionFile.class.php

Go to the documentation of this file.
00001 <?php
00021 class CodeReflectionFile
00022 {
00028     protected static $arrInstances = array();
00029 
00035     protected $strFileName;
00036 
00042     protected $arrFileContent;
00043 
00051     protected $boolRealFile;
00052 
00063     public static function getCodeInstrFileName( $strFileName )
00064     {
00065         if( array_key_exists( $strFileName , self::$arrInstances ) )
00066         {
00067             return      self::$arrInstances[ $strFileName ];
00068         }
00069         else
00070         {
00071             return new CodeReflectionFile( $strFileName );
00072         }
00073     }
00074 
00085     public function __construct( $strFileName , $strFileContent = ""  , $boolRealFile = true )
00086     {
00087         $this->setFileName( $strFileName);
00088         $this->setFileContent( $strFileContent );
00089         $this->boolRealFile = (bool)$boolRealFile;
00090         self::$arrInstances[ $strFileName ] = $this;
00091     }
00092 
00101     public function setFileName( $strFileName )
00102     {
00103         $this->strFileName = (string)$strFileName;
00104         return $this;
00105     }
00106 
00114     public function getFileName()
00115     {
00116         return $this->strFileName;
00117     }
00118 
00129     public function setFileContent( $strFileContent )
00130     {
00131         $this->arrFileContent = explode( "\n" , (string)$strFileContent );
00132         return $this;
00133     }
00134 
00142     public function getFileContent()
00143     {
00144         return implode( "\n" , $this->arrFileContent );
00145     }
00146 
00158     public function getArrFileContent()
00159     {
00160         return $this->arrFileContent;
00161     }
00162 
00174     public function getFileBit( $intLineStart, $intLineEnds )
00175     {
00176         $strFileBit = "";
00177 
00178         if( $this->isRealFile() )
00179         {
00180             $this->setFileContent( $this->getFileName() );
00181         }
00182 
00183         for( $intLine = $intLineStart ; $intLine < $intLineEnds ; ++$intLine )
00184         {
00185             $strFileBit .= CorujaArrayManipulation::getArrayField( $this->arrFileContent ,$intLine , "") . "\n";
00186         }
00187         return $strFileBit;
00188     }
00189 
00196     public function isRealFile()
00197     {
00198         return $this->boolRealFile;
00199     }
00200 }
00201 ?>

Generated on Thu Feb 3 03:54:59 2011 for CodeToDiagram by  doxygen 1.5.9