Conditions | 4 |
Paths | 4 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
26 | public function remove(string $uploader, array $userData) |
||
27 | { |
||
28 | /** @var UploaderInterface $uploader */ |
||
29 | $uploader = new $uploader(); |
||
30 | if (false === is_a($uploader, UploaderInterface::class)) { |
||
31 | throw new Exception('Uploader class must be instanceof UploaderInterface', 500); |
||
32 | } |
||
33 | if (is_a($uploader, AccessRemoveInterface::class)) { |
||
34 | /** @var UploaderInterface|AccessRemoveInterface $uploader */ |
||
35 | if ($uploader->canRemove($userData)) { |
||
|
|||
36 | return $uploader->remove($userData); |
||
37 | } else { |
||
38 | return $uploader->deniedRemove($userData); |
||
39 | } |
||
40 | } else { |
||
41 | return $uploader->remove($userData); |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 |
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: