Conditions | 3 |
Paths | 3 |
Total Lines | 38 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 7 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
31 | public function handle($request, Closure $next) { |
||
32 | foreach ($request->file() as $name => $value) { |
||
|
|||
33 | |||
34 | /** |
||
35 | * All media |
||
36 | */ |
||
37 | $request->merge( |
||
38 | [ |
||
39 | $name . '_mime_type' => $request->file($name)->getMimeType(), |
||
40 | $name . '_original_extension' => $request->file($name)->getClientOriginalExtension(), |
||
41 | $name . '_original_name' => $request->file($name)->getClientOriginalName(), |
||
42 | $name . '_extension' => pathinfo($request->file($name)->getClientOriginalName(), PATHINFO_EXTENSION), |
||
43 | $name . '_size' => filesize($request->file($name)->getRealPath()), |
||
44 | $name . '_etag' => sha1_file($request->file($name)->getRealPath()), |
||
45 | ]); |
||
46 | |||
47 | /** |
||
48 | * Images |
||
49 | */ |
||
50 | if (str_contains($name . '_mime_type', 'image')) { |
||
51 | list($width, $height) = (getimagesize($request->file($name)->getRealPath())); |
||
52 | $request->merge( |
||
53 | [ |
||
54 | $name . '_width' => $width, |
||
55 | $name . '_height' => $height, |
||
56 | ]); |
||
57 | |||
58 | |||
59 | $request->merge( |
||
60 | [ |
||
61 | $name => $request->file($name)->getRealPath() |
||
62 | ]); |
||
63 | /* } */ |
||
64 | } |
||
65 | } |
||
66 | |||
67 | return $next($request); |
||
68 | } |
||
69 | } |
||
70 |
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.