1 | <?php |
||||||
2 | |||||||
3 | |||||||
4 | namespace NovaThinKit\FeatureImage\Models; |
||||||
5 | |||||||
6 | use Illuminate\Support\Str; |
||||||
7 | use NovaThinKit\FeatureImage\FeatureImageManager; |
||||||
8 | use NovaThinKit\FeatureImage\ImageManager; |
||||||
9 | |||||||
10 | trait HasFeatureImage |
||||||
11 | { |
||||||
12 | protected ?ImageManager $featureImageManager = null; |
||||||
13 | |||||||
14 | 1 | protected function createFeatureImageManager(?string $tag = null): ImageManager |
|||||
0 ignored issues
–
show
|
|||||||
15 | { |
||||||
16 | 1 | if (!$this->featureImageManager) { |
|||||
17 | 1 | $featureImageManagerConfig = property_exists($this, 'featureImageManagerConfig') ? $this->featureImageManagerConfig : 'nova-thinkit.feature-images.default'; |
|||||
18 | 1 | $this->featureImageManager = FeatureImageManager::fromConfig(config($featureImageManagerConfig)); |
|||||
19 | } |
||||||
20 | |||||||
21 | 1 | return $this->featureImageManager; |
|||||
22 | } |
||||||
23 | |||||||
24 | 17 | public function featureImageManager(?string $tag = null): ImageManager |
|||||
25 | { |
||||||
26 | 17 | return $this->createFeatureImageManager($tag) |
|||||
27 | 17 | ->setTag($tag) |
|||||
0 ignored issues
–
show
The method
setTag() does not exist on NovaThinKit\FeatureImage\ImageManager . Since it exists in all sub-types, consider adding an abstract or default implementation to NovaThinKit\FeatureImage\ImageManager .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
28 | 17 | ->setModel($this); |
|||||
29 | } |
||||||
30 | |||||||
31 | |||||||
32 | 1 | public function featureImageManagerDirectory(?string $tag = null): string |
|||||
0 ignored issues
–
show
The parameter
$tag is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
33 | { |
||||||
34 | 1 | $class = $this->getMorphClass(); |
|||||
0 ignored issues
–
show
It seems like
getMorphClass() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
35 | |||||||
36 | 1 | $path = Str::contains($class, '\\') ? class_basename($class) : $class; |
|||||
37 | |||||||
38 | 1 | return base64_encode($path . '-' . $this->getKey()); |
|||||
0 ignored issues
–
show
It seems like
getKey() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
39 | } |
||||||
40 | |||||||
41 | 3 | public function featureImageKey(?string $tag = null): string |
|||||
42 | { |
||||||
43 | 3 | return $tag ?: 'image'; |
|||||
44 | } |
||||||
45 | } |
||||||
46 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.