| Conditions | 3 |
| Paths | 2 |
| Total Lines | 13 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 1 | public function map($type) |
|
| 26 | { |
||
| 27 | 1 | $mapping = []; |
|
| 28 | 1 | if (is_dir($type)) { |
|
| 29 | 1 | exec('find '.$type.' -name "*.'.$type.'" -exec md5sum {} \; | sort', $contents); |
|
| 30 | 1 | foreach ($contents as $i => $row) { |
|
|
|
|||
| 31 | 1 | list($hash, $file) = explode(" ", $row); |
|
| 32 | 1 | $file = substr($file, strlen($type) + 1); |
|
| 33 | 1 | $mapping[$file] = $hash; |
|
| 34 | } |
||
| 35 | } |
||
| 36 | 1 | return $mapping; |
|
| 37 | } |
||
| 38 | } |
||
| 39 |
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.