| Conditions | 6 |
| Paths | 5 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 6 | public static function hashDirectory(string $path): string |
|
| 16 | { |
||
| 17 | 6 | if (!Filesystem::is_dir($path)) { |
|
| 18 | 2 | throw new RuntimeException("The given directory '$path' can not be found."); |
|
| 19 | } |
||
| 20 | |||
| 21 | 4 | $files = []; |
|
| 22 | 4 | $dir = Filesystem::dir($path); |
|
| 23 | |||
| 24 | 4 | while (($file = $dir->read()) !== false) { |
|
| 25 | 4 | if ($file !== '.' && $file !== '..') { |
|
| 26 | 4 | $files[] = Filesystem::is_dir($path . '/' . $file) |
|
| 27 | 2 | ? self::hashDirectory($path . '/' . $file) |
|
| 28 | 4 | : self::hashFile($path . '/' . $file); |
|
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | 4 | $dir->close(); |
|
| 33 | |||
| 34 | 4 | return self::hashString(implode('', $files)); |
|
| 35 | } |
||
| 51 |