| Conditions | 5 |
| Paths | 3 |
| Total Lines | 25 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public function hashPath($path) |
||
| 18 | { |
||
| 19 | $path = realpath($path); |
||
| 20 | $hashes = []; |
||
| 21 | |||
| 22 | if (is_dir($path)) { |
||
| 23 | $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); |
||
| 24 | |||
| 25 | /** @var SplFileInfo $file */ |
||
| 26 | foreach ($it as $file) { |
||
| 27 | if ($file->isFile()) { |
||
| 28 | $hashes[] = md5_file($file) . '-' . $this->hashPathName((string)$file); |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | if (empty($hashes)) { |
||
| 33 | $hashes[] = 'null-' . $this->hashPathName($path); |
||
| 34 | } else { |
||
| 35 | sort($hashes); |
||
| 36 | } |
||
| 37 | } else { |
||
| 38 | $hashes[] = md5_file($path) . '-' . $this->hashPathName((string)$path); |
||
| 39 | } |
||
| 40 | |||
| 41 | return md5(implode('|', $hashes)); |
||
| 42 | } |
||
| 58 |