CodeReflectionFile Class Reference

List of all members.

Public Member Functions

 __construct ($strFileName, $strFileContent="", $boolRealFile=true)
 setFileName ($strFileName)
 getFileName ()
 setFileContent ($strFileContent)
 getFileContent ()
 getArrFileContent ()
 getFileBit ($intLineStart, $intLineEnds)
 isRealFile ()

Static Public Member Functions

static getCodeInstrFileName ($strFileName)

Protected Attributes

 $strFileName
 $arrFileContent
 $boolRealFile

Static Protected Attributes

static $arrInstances = array()


Detailed Description

Code Reflection File it is a class with the prupose to make possible abstract the diference between code run into real files and code run into eval commands.

In this mode this class keep the alias fake name of the alias content and the file content, this information can be access by others classes what will be able to interaction with the fake file.

You can get a streck of code of the memory file or the real file using the same method send the first line and last line of the bit of code what you want to receive.

Author:
Thiago Henrique Ramos da Mata <thiago.henrique.mata@gmail.com>

Definition at line 21 of file CodeReflectionFile.class.php.


Constructor & Destructor Documentation

__construct ( strFileName,
strFileContent = "",
boolRealFile = true 
)

Create the Code Reflection File

See also:
CodeReflectionFile::$arrInstances

CodeReflectionFile::setFileName( string )

CodeReflectionFile::setFileContent( string )

Parameters:
string $strFileName file name
string $strFileContent file content
boolean $boolRealFile if is a real file or not

Definition at line 85 of file CodeReflectionFile.class.php.

References $boolRealFile, $strFileName, setFileContent(), and setFileName().

00086     {
00087         $this->setFileName( $strFileName);
00088         $this->setFileContent( $strFileContent );
00089         $this->boolRealFile = (bool)$boolRealFile;
00090         self::$arrInstances[ $strFileName ] = $this;
00091     }


Member Function Documentation

getArrFileContent (  ) 

Get the array of lines with the code file content

Set the code file content and return itselft.

See also:
CodeReflectionFile->arrFileContent

CodeReflectionFile::setFileContent( string )

CodeReflectionFile::getFileContent()

Returns:
string[] array of file content

Definition at line 158 of file CodeReflectionFile.class.php.

00159     {
00160         return $this->arrFileContent;
00161     }

static getCodeInstrFileName ( strFileName  )  [static]

Get The File by Name

Search into all object files saved and return that one have the searched name

See also:
CodeReflectionFile->arrInstances
Parameters:
string $strFileName
Returns:
CodeReflectionFile

Definition at line 63 of file CodeReflectionFile.class.php.

References $strFileName.

Referenced by CodeReflectionFunction::createFunctionContentCode(), CodeReflectionMethod::createMethodContentCode(), and CodeInstrumentationMethod::createMethodContentCode().

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     }

getFileBit ( intLineStart,
intLineEnds 
)

Get a slice, a streck, a bit of the content of the file receiving the first and last line of the slice wish.

See also:
CodeReflectionFile::setFileContent( string )

CodeReflectionFile->arrFileContent

CodeReflectionFile->arrFileContent

Parameters:
integer $intLineStart first line of the content
integer $intLineEnds last line of the content
Returns:
string code content

Definition at line 174 of file CodeReflectionFile.class.php.

References CorujaArrayManipulation::getArrayField(), getFileName(), isRealFile(), and setFileContent().

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     }

getFileContent (  ) 

Get the file content

See also:
CodeReflectionFile->arrFileContent

CodeReflectionFile::setFileContent( string )

Returns:
string file content

Definition at line 142 of file CodeReflectionFile.class.php.

00143     {
00144         return implode( "\n" , $this->arrFileContent );
00145     }

getFileName (  ) 

Get the file name

See also:
CodeReflectionFile::setFileName( string )

CodeReflectionFile->strFileName

Returns:
string file name

Definition at line 114 of file CodeReflectionFile.class.php.

Referenced by getFileBit().

00115     {
00116         return $this->strFileName;
00117     }

isRealFile (  ) 

Returns if the file it is a real file

See also:
CodeReflectionFile->boolRealFile
Returns:
boolean true if is a real file false if not

Definition at line 196 of file CodeReflectionFile.class.php.

Referenced by getFileBit().

00197     {
00198         return $this->boolRealFile;
00199     }

setFileContent ( strFileContent  ) 

Set the code Reflection file content

Set the code Reflection file content and return itselft.

See also:
CodeReflectionFile->arrFileContent
Parameters:
string $strFileContent file content
Returns:
CodeReflectionFile me

Definition at line 129 of file CodeReflectionFile.class.php.

Referenced by __construct(), and getFileBit().

00130     {
00131         $this->arrFileContent = explode( "\n" , (string)$strFileContent );
00132         return $this;
00133     }

setFileName ( strFileName  ) 

Set the file name

See also:
CodeReflectionFile::getFileName()

CodeReflectionFile->strFileName

Parameters:
string $strFileName file name
Returns:
CodeReflectionFile me

Definition at line 101 of file CodeReflectionFile.class.php.

References $strFileName.

Referenced by __construct().

00102     {
00103         $this->strFileName = (string)$strFileName;
00104         return $this;
00105     }


Member Data Documentation

$arrFileContent [protected]

File Content

string

Definition at line 42 of file CodeReflectionFile.class.php.

$arrInstances = array() [static, protected]

array of all instances of CodeReflectionFile using the name as key

CodeReflectionFile[]

Definition at line 28 of file CodeReflectionFile.class.php.

$boolRealFile [protected]

Flag if the file it is a real file true if is a real file false if is a not real file

boolean

Definition at line 51 of file CodeReflectionFile.class.php.

Referenced by __construct().

$strFileName [protected]

File Name

string

Definition at line 35 of file CodeReflectionFile.class.php.

Referenced by __construct(), getCodeInstrFileName(), and setFileName().


The documentation for this class was generated from the following file:

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