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