1 | <?php |
||
2 | |||
3 | namespace Mostafaznv\Larupload\Actions; |
||
4 | |||
5 | use Illuminate\Support\Str; |
||
6 | use Mostafaznv\Larupload\DTOs\Style\Style; |
||
7 | use Mostafaznv\Larupload\Larupload; |
||
8 | |||
9 | /** |
||
10 | * In some special cases we should use other file names instead of the original one. |
||
11 | * |
||
12 | * Example: when user uploads a svg image, we should change the converted format to jpg! |
||
13 | * so we have to manipulate file name |
||
14 | */ |
||
15 | class FixExceptionNamesAction |
||
16 | { |
||
17 | public function __construct( |
||
18 | private readonly string $name, |
||
19 | private readonly string $styleName, |
||
20 | private readonly ?Style $style = null, |
||
21 | ) {} |
||
22 | |||
23 | public static function make(string $name, string $styleName, ?Style $style = null): self |
||
24 | { |
||
25 | return new self($name, $styleName, $style); |
||
26 | } |
||
27 | |||
28 | |||
29 | public function run(): string |
||
30 | { |
||
31 | $name = $this->name; |
||
32 | |||
33 | if ($this->style) { |
||
34 | $name = larupload_style_path($name, $this->style->extension()); |
||
0 ignored issues
–
show
|
|||
35 | } |
||
36 | |||
37 | if (!in_array($this->styleName, [Larupload::ORIGINAL_FOLDER, Larupload::COVER_FOLDER])) { |
||
38 | if (Str::endsWith($name, 'svg')) { |
||
39 | return str_replace('svg', 'jpg', $name); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | return $name; |
||
44 | } |
||
45 | } |
||
46 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.