Last active
November 27, 2020 21:28
-
-
Save phoshp/b13fec79481e746225179f45e31d4b5a to your computer and use it in GitHub Desktop.
A basic php script for lazy devs to know how much line they have coded
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 | |
$dirs = [ | |
// ADD YOUR DIRS | |
]; | |
$targetExtensions = [ | |
// EXAMPLE | |
"php" => true, | |
"css" => true | |
]; | |
$codeline = 0; | |
foreach($dirs as $dir){ | |
$dir = str_replace("\\", "/", $dir); | |
if(!is_dir($dir)){ | |
print_r("There is not a directory with path name: " . $dir . "\n"); | |
continue; | |
} | |
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)) as $file){ | |
$path = $file->getPathname(); | |
if(isset($targetExtensions[$file->getExtension()])){ | |
$content = file_get_contents($path); | |
$codeline += substr_count($content, "\n") + 1; | |
} | |
} | |
} | |
print_r("Total Code Line: " . $codeline); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment