MediaPathGenerator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPath() 0 9 2
A getPathForResponsiveImages() 0 3 1
A getPathForConversions() 0 3 1
1
<?php
2
3
namespace App\Config;
4
5
use CleaniqueCoders\LaravelUuid\Contracts\HasUuid as HasUuidContract;
0 ignored issues
show
Bug introduced by
The type CleaniqueCoders\LaravelUuid\Contracts\HasUuid was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Spatie\MediaLibrary\Models\Media;
0 ignored issues
show
Bug introduced by
The type Spatie\MediaLibrary\Models\Media was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Spatie\MediaLibrary\PathGenerator\PathGenerator;
0 ignored issues
show
Bug introduced by
The type Spatie\MediaLibrary\PathGenerator\PathGenerator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
class MediaPathGenerator implements PathGenerator
10
{
11
    public function getPath(Media $media): string
12
    {
13
        $id = $media->id;
14
15
        if ($media instanceof HasUuidContract) {
16
            $id = $media->getUuidColumnName();
17
        }
18
19
        return $media->collection_name . DIRECTORY_SEPARATOR . $id;
20
    }
21
22
    public function getPathForConversions(Media $media): string
23
    {
24
        return $this->getPath($media) . 'conversions' . DIRECTORY_SEPARATOR;
25
    }
26
27
    public function getPathForResponsiveImages(Media $media): string
28
    {
29
        return $this->getPath($media) . 'responsives' . DIRECTORY_SEPARATOR;
30
    }
31
}
32