Skip to content

Instantly share code, notes, and snippets.

@m3m0r7
Created August 15, 2016 09:20
Show Gist options
  • Save m3m0r7/24ff52231e0a1f3aaf9ec8a65c9bc8fc to your computer and use it in GitHub Desktop.
Save m3m0r7/24ff52231e0a1f3aaf9ec8a65c9bc8fc to your computer and use it in GitHub Desktop.
<?php
/**
* あなたがどれくらい今日仕事したのか調べるやつです。
*/
mb_internal_encoding('UTF-8');
$files = 0;
$lines = 0;
$bytes = 0;
$mbytes = 0;
$e = function ($d, $r = [], $t = false) use (&$e, &$files, &$lines, &$bytes, &$mbytes) {
foreach (glob($d . '/*') as $v) {
$n = basename($v);
if (!in_array($n, $r) && is_dir($v)) {
$e($v, $r, $t);
continue;
} else if (is_file($v)) {
if ($t === true || filemtime($v) >= strtotime(date('Y-m-d 00:00:00'))) {
$files++;
$h = fopen($v, 'r');
while ($l = fgets($h)) {
if (!(trim($l) === ' ' || $l === '')) {
$lines++;
$bytes += strlen($l);
$mbytes += mb_strlen($l);
}
}
}
}
}
};
$e('/path/to', [/* 除外したいディレクトリを配列で! */], true/* trueの場合はタイムスタンプを無視します。デフォルトはfalse */);
printf("Added / Changed Files : %s file(s)\n", number_format($files));
printf("Lines : %s line(s)\n", number_format($lines));
printf("Bytes : %s byte\n", number_format($bytes));
printf("Multi Bytes : %s byte\n", number_format($mbytes));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment