| Conditions | 4 | 
| Paths | 4 | 
| Total Lines | 30 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 11 | public function __construct(string $filename)  | 
            ||
| 12 |     { | 
            ||
| 13 |         $disk = Storage::disk(config('personal-data-export.disk')); | 
            ||
| 14 | |||
| 15 |         if (! $disk->exists($filename)) { | 
            ||
| 16 | abort(404);  | 
            ||
| 17 | }  | 
            ||
| 18 | |||
| 19 | $downloadFilename = auth()->user()  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 20 | ? auth()->user()->personalDataExportName()  | 
            ||
| 21 | : $filename;  | 
            ||
| 22 | |||
| 23 | $downloadHeaders = [  | 
            ||
| 24 | 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',  | 
            ||
| 25 | 'Content-Type' => 'application/zip',  | 
            ||
| 26 | 'Content-Length' => $disk->size($filename),  | 
            ||
| 27 | 'Content-Disposition' => 'attachment; filename="'.$downloadFilename.'"',  | 
            ||
| 28 | 'Pragma' => 'public',  | 
            ||
| 29 | ];  | 
            ||
| 30 | |||
| 31 |         parent::__construct(function () use ($filename, $disk) { | 
            ||
| 32 | $stream = $disk->readStream($filename);  | 
            ||
| 33 | |||
| 34 | fpassthru($stream);  | 
            ||
| 35 | |||
| 36 |             if (is_resource($stream)) { | 
            ||
| 37 | fclose($stream);  | 
            ||
| 38 | }  | 
            ||
| 39 | }, Response::HTTP_OK, $downloadHeaders);  | 
            ||
| 40 | }  | 
            ||
| 41 | }  | 
            ||
| 42 | 
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: