src/FS/File/CodeLineCounter.php
public static function countLinesFromSource( $content )
	{
		$counter		= 0;
		$numberCodes	= 0;
		$numberDocs		= 0;
		$numberStrips	= 0;
		$linesCodes		= array();
		$linesDocs		= array();
		$linesStrips	= array();

		$lines		= explode( "\n", $content );
		foreach( $lines as $line )
		{
			if( preg_match( "@^(\t| )*/?\*@", $line ) )
			{
				$linesDocs[$counter] = $line;
				$numberDocs++;
			}
			else if( preg_match( "@^(<\?php|<\?|\?>|\}|\{|\t| )*$@", trim( $line ) ) )
			{
				$linesStrips[$counter] = $line;
				$numberStrips++;
			}
			else if( preg_match( "@^(public|protected|private|class|function|final|define|import)@", trim( $line ) ) )
			{
				$linesStrips[$counter] = $line;
				$numberStrips++;
			}
			else
			{
				$linesCodes[$counter] = $line;
				$numberCodes++;
			}
			$counter ++;
		}
		$data	= array(
			'length'		=> strlen( $content ),
			'numberCodes'	=> $numberCodes,
			'numberDocs'	=> $numberDocs,
			'numberStrips'	=> $numberStrips,
			'linesTotal'	=> $counter,
			'linesCodes'	=> $linesCodes,
			'linesDocs'		=> $linesDocs,
			'linesStrips'	=> $linesStrips,
			'ratioCodes'	=> $numberCodes / $counter * 100,
			'ratioDocs'		=> $numberDocs / $counter * 100,
			'ratioStrips'	=> $numberStrips / $counter * 100,
		);
		return $data;
	}
public static function countLinesFromSource( $content )
	{
		$counter		= 0;
		$numberCodes	= 0;
		$numberDocs		= 0;
		$numberStrips	= 0;
		$linesCodes		= array();
		$linesDocs		= array();
		$linesStrips	= array();

		$lines		= explode( "\n", $content );
		foreach( $lines as $line )
		{
			if( preg_match( "@^(\t| )*/?\*@", $line ) )
			{
				$linesDocs[$counter] = $line;
				$numberDocs++;
			}
			else if( preg_match( "@^(<\?php|<\?|\?>|\}|\{|\t| )*$@", trim( $line ) ) )
			{
				$linesStrips[$counter] = $line;
				$numberStrips++;
			}
			else if( preg_match( "@^(public|protected|private|class|function|final|define|import)@", trim( $line ) ) )
			{
				$linesStrips[$counter] = $line;
				$numberStrips++;
			}
			else
			{
				$linesCodes[$counter] = $line;
				$numberCodes++;
			}
			$counter ++;
		}
		$data	= array(
			'length'		=> strlen( $content ),
			'numberCodes'	=> $numberCodes,
			'numberDocs'	=> $numberDocs,
			'numberStrips'	=> $numberStrips,
			'linesTotal'	=> $counter,
			'linesCodes'	=> $linesCodes,
			'linesDocs'		=> $linesDocs,
			'linesStrips'	=> $linesStrips,
			'ratioCodes'	=> $numberCodes / $counter * 100,
			'ratioDocs'		=> $numberDocs / $counter * 100,
			'ratioStrips'	=> $numberStrips / $counter * 100,
		);
		return $data;
	}
public static function countLinesFromSource ( $ content ) { $ counter = 0 ; $ numberCodes = 0 ; $ numberDocs = 0 ; $ numberStrips = 0 ; $ linesCodes = array ( ) ; $ linesDocs = array ( ) ; $ linesStrips = array ( ) ; $ lines = explode ( "\n" , $ content ) ; foreach ( $ lines as $ line ) { if ( preg_match ( "@^(\t| )*/?\*@" , $ line ) ) { $ linesDocs [ $ counter ] = $ line ; $ numberDocs ++ ; } else if ( preg_match ( "@^(<\?php|<\?|\?>|\}|\{|\t| )*$@" , trim ( $ line ) ) ) { $ linesStrips [ $ counter ] = $ line ; $ numberStrips ++ ; } else if ( preg_match ( "@^(public|protected|private|class|function|final|define|import)@" , trim ( $ line ) ) ) { $ linesStrips [ $ counter ] = $ line ; $ numberStrips ++ ; } else { $ linesCodes [ $ counter ] = $ line ; $ numberCodes ++ ; } $ counter ++ ; } $ data = array ( 'length' => strlen ( $ content ) , 'numberCodes' => $ numberCodes , 'numberDocs' => $ numberDocs , 'numberStrips' => $ numberStrips , 'linesTotal' => $ counter , 'linesCodes' => $ linesCodes , 'linesDocs' => $ linesDocs , 'linesStrips' => $ linesStrips , 'ratioCodes' => $ numberCodes / $ counter * 100 , 'ratioDocs' => $ numberDocs / $ counter * 100 , 'ratioStrips' => $ numberStrips / $ counter * 100 , ) ; return $ data ; }
Reads File and counts Code Lines, Documentation Lines and unimportant Lines and returns a Data Array.
@access		public
@static
@param		string		$content		Source Code of File
@return		array
Reads File and counts Code Lines Documentation Lines and unimportant Lines and returns a Data Array .