src/FS/Folder/CodeLineCounter.php
public function readFolder( $path, $extensions = array() )
	{
		$files			= array();
		$numberCodes	= 0;
		$numberDocs		= 0;
		$numberFiles	= 0;
		$numberLength	= 0;
		$numberLines	= 0;
		$numberStrips	= 0;

		$path	= preg_replace( "@^(.+)/?$@", "\\1/", $path );

		$st		= new Alg_Time_Clock();
		$lister	= new FS_Folder_RecursiveLister( $path );
		$lister->setExtensions( $extensions );
		$list	= $lister->getList();
		foreach( $list as $entry )
		{
			$fileName	= str_replace( "\\", "/", $entry->getFilename() );
			$pathName	= str_replace( "\\", "/", $entry->getPathname() );
			
			if( substr( $fileName, 0, 1 ) == "_" )
				continue;
			if( preg_match( "@/_@", $pathName ) )
				continue;

			$countData	= FS_File_CodeLineCounter::countLines( $pathName );
			
			unset( $countData['linesCodes'] );
			unset( $countData['linesDocs'] );
			unset( $countData['linesStrips'] );

			$numberLength		+= $countData['length'];
			$numberLines		+= $countData['linesTotal'];
			
			$numberFiles		++;
			$numberStrips		+= $countData['numberStrips'];
			$numberCodes		+= $countData['numberCodes'];
			$numberDocs			+= $countData['numberDocs'];
			$files[$pathName]	= $countData;
		}
		$linesPerFile	= $numberLines / $numberFiles;
		$this->data	= array(
			'number'	=> array(
				'files'		=> $numberFiles,
				'lines'		=> $numberLines,
				'codes'		=> $numberCodes,
				'docs'		=> $numberDocs,
				'strips'	=> $numberStrips,
				'length'	=> $numberLength,
			),
			'ratio'			=> array(
				'linesPerFile'		=> round( $linesPerFile, 0 ),
				'codesPerFile'		=> round( $numberCodes / $numberFiles, 0 ),
				'docsPerFile'		=> round( $numberDocs / $numberFiles, 0 ),
				'stripsPerFile'		=> round( $numberStrips / $numberFiles, 0 ),
				'codesPerFile%'		=> round( $numberCodes / $numberFiles / $linesPerFile * 100, 1 ),
				'docsPerFile%'		=> round( $numberDocs / $numberFiles / $linesPerFile * 100, 1 ),
				'stripsPerFile%'	=> round( $numberStrips / $numberFiles / $linesPerFile * 100, 1 ),
			), 
			'files'		=> $files,
			'seconds'	=> $st->stop( 6 ),
			'path'		=> $path,
		);
	}
public function readFolder( $path, $extensions = array() )
	{
		$files			= array();
		$numberCodes	= 0;
		$numberDocs		= 0;
		$numberFiles	= 0;
		$numberLength	= 0;
		$numberLines	= 0;
		$numberStrips	= 0;

		$path	= preg_replace( "@^(.+)/?$@", "\\1/", $path );

		$st		= new Alg_Time_Clock();
		$lister	= new FS_Folder_RecursiveLister( $path );
		$lister->setExtensions( $extensions );
		$list	= $lister->getList();
		foreach( $list as $entry )
		{
			$fileName	= str_replace( "\\", "/", $entry->getFilename() );
			$pathName	= str_replace( "\\", "/", $entry->getPathname() );
			
			if( substr( $fileName, 0, 1 ) == "_" )
				continue;
			if( preg_match( "@/_@", $pathName ) )
				continue;

			$countData	= FS_File_CodeLineCounter::countLines( $pathName );
			
			unset( $countData['linesCodes'] );
			unset( $countData['linesDocs'] );
			unset( $countData['linesStrips'] );

			$numberLength		+= $countData['length'];
			$numberLines		+= $countData['linesTotal'];
			
			$numberFiles		++;
			$numberStrips		+= $countData['numberStrips'];
			$numberCodes		+= $countData['numberCodes'];
			$numberDocs			+= $countData['numberDocs'];
			$files[$pathName]	= $countData;
		}
		$linesPerFile	= $numberLines / $numberFiles;
		$this->data	= array(
			'number'	=> array(
				'files'		=> $numberFiles,
				'lines'		=> $numberLines,
				'codes'		=> $numberCodes,
				'docs'		=> $numberDocs,
				'strips'	=> $numberStrips,
				'length'	=> $numberLength,
			),
			'ratio'			=> array(
				'linesPerFile'		=> round( $linesPerFile, 0 ),
				'codesPerFile'		=> round( $numberCodes / $numberFiles, 0 ),
				'docsPerFile'		=> round( $numberDocs / $numberFiles, 0 ),
				'stripsPerFile'		=> round( $numberStrips / $numberFiles, 0 ),
				'codesPerFile%'		=> round( $numberCodes / $numberFiles / $linesPerFile * 100, 1 ),
				'docsPerFile%'		=> round( $numberDocs / $numberFiles / $linesPerFile * 100, 1 ),
				'stripsPerFile%'	=> round( $numberStrips / $numberFiles / $linesPerFile * 100, 1 ),
			), 
			'files'		=> $files,
			'seconds'	=> $st->stop( 6 ),
			'path'		=> $path,
		);
	}
public function readFolder ( $ path , $ extensions = array ( ) ) { $ files = array ( ) ; $ numberCodes = 0 ; $ numberDocs = 0 ; $ numberFiles = 0 ; $ numberLength = 0 ; $ numberLines = 0 ; $ numberStrips = 0 ; $ path = preg_replace ( "@^(.+)/?$@" , "\\1/" , $ path ) ; $ st = new Alg_Time_Clock ( ) ; $ lister = new FS_Folder_RecursiveLister ( $ path ) ; $ lister -> setExtensions ( $ extensions ) ; $ list = $ lister -> getList ( ) ; foreach ( $ list as $ entry ) { $ fileName = str_replace ( "\\" , "/" , $ entry -> getFilename ( ) ) ; $ pathName = str_replace ( "\\" , "/" , $ entry -> getPathname ( ) ) ; if ( substr ( $ fileName , 0 , 1 ) == "_" ) continue ; if ( preg_match ( "@/_@" , $ pathName ) ) continue ; $ countData = FS_File_CodeLineCounter :: countLines ( $ pathName ) ; unset ( $ countData [ 'linesCodes' ] ) ; unset ( $ countData [ 'linesDocs' ] ) ; unset ( $ countData [ 'linesStrips' ] ) ; $ numberLength += $ countData [ 'length' ] ; $ numberLines += $ countData [ 'linesTotal' ] ; $ numberFiles ++ ; $ numberStrips += $ countData [ 'numberStrips' ] ; $ numberCodes += $ countData [ 'numberCodes' ] ; $ numberDocs += $ countData [ 'numberDocs' ] ; $ files [ $ pathName ] = $ countData ; } $ linesPerFile = $ numberLines / $ numberFiles ; $ this -> data = array ( 'number' => array ( 'files' => $ numberFiles , 'lines' => $ numberLines , 'codes' => $ numberCodes , 'docs' => $ numberDocs , 'strips' => $ numberStrips , 'length' => $ numberLength , ) , 'ratio' => array ( 'linesPerFile' => round ( $ linesPerFile , 0 ) , 'codesPerFile' => round ( $ numberCodes / $ numberFiles , 0 ) , 'docsPerFile' => round ( $ numberDocs / $ numberFiles , 0 ) , 'stripsPerFile' => round ( $ numberStrips / $ numberFiles , 0 ) , 'codesPerFile%' => round ( $ numberCodes / $ numberFiles / $ linesPerFile * 100 , 1 ) , 'docsPerFile%' => round ( $ numberDocs / $ numberFiles / $ linesPerFile * 100 , 1 ) , 'stripsPerFile%' => round ( $ numberStrips / $ numberFiles / $ linesPerFile * 100 , 1 ) , ) , 'files' => $ files , 'seconds' => $ st -> stop ( 6 ) , 'path' => $ path , ) ; }
Counts Files, Folders, Lines of Code and other statistical Information.
@access		public
@param		string		$path			Folder to count within
@param		array		$extensions		List of Code File Extensions
@return		array
Counts Files Folders Lines of Code and other statistical Information .