Conditions | 3 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
26 | public function map($type) |
||
27 | { |
||
28 | $mapping = []; |
||
29 | if (is_dir($type)) { |
||
30 | exec('find '.$type.' -name "*.'.$type.'" -exec md5sum {} \; | sort', $contents); |
||
31 | foreach ($contents as $i => $row) { |
||
|
|||
32 | list($hash, $file) = explode(" ", $row); |
||
33 | $file = substr($file, strlen($type) + 1); |
||
34 | $mapping[$file] = $hash; |
||
35 | } |
||
36 | } |
||
37 | return $mapping; |
||
38 | } |
||
39 | } |
||
40 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.