Last active
December 12, 2015 01:38
-
-
Save bdelespierre/4692858 to your computer and use it in GitHub Desktop.
Ever wondered how many lines you've written in your PHP project ? This is almost the most useless script in history but I'm kinda curious so I wrote it anyway...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
set_time_limit(0); | |
function glob_recursive($pattern, $flags = 0) { | |
$files = glob($pattern, $flags); | |
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { | |
$files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags)); | |
} | |
return $files; | |
} | |
$files = 0; | |
$lines = 0; | |
foreach (glob_recursive('*.php') as $file) { | |
if (strpos($file, 'jpgraph') !== false) continue; | |
$files++; | |
$file = new SplFileObject($file); | |
foreach ($file as $line) { | |
if (trim($line)) | |
$lines++; | |
} | |
unset($file); | |
} | |
PHP_SAPI != 'cli' && header("Content-Type: text/plain"); | |
echo dirname(__FILE__)." has $files PHP scripts with a total of $lines non empty code lines"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment