PHP - How to count lines of code in an application -
this question has answer here:
- count lines in php project [closed] 7 answers
i need count number of lines of code within application (in php, not command line), , since snippets on web didn't much, i've decided ask here. reply!
edit
actually, need whole snippet scanning , counting lines within given folder. i'm using method in cakephp, i'd appreciate seamless integration.
to on directory, i'd use iterator.
function countlines($path, $extensions = array('php')) { $it = new recursiveiteratoriterator( new recursivedirectoryiterator($path) ); $files = array(); foreach ($it $file) { if ($file->isdir() || $file->isdot()) { continue; } $parts = explode('.', $file->getfilename()); $extension = end($parts); if (in_array($extension, $extensions)) { $files[$file->getpathname()] = count(file($file->getpathname())); } } return $files; }
that return array each file key , number of lines value. then, if want total, array_sum(countlines($path));
...
Comments
Post a Comment