XetaravelPathGenerator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPathForResponsiveImages() 0 3 1
A getPath() 0 3 1
A getPathForConversions() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\MediaLibrary\PathGenerator;
6
7
use Spatie\MediaLibrary\MediaCollections\Models\Media;
8
use Spatie\MediaLibrary\Support\PathGenerator\PathGenerator;
9
10
class XetaravelPathGenerator implements PathGenerator
11
{
12
    /**
13
     * Get the path for the given media, relative to the root storage path.
14
     *
15
     * @param Media $media
16
     *
17
     * @return string
18
     */
19
    public function getPath(Media $media): string
20
    {
21
        return $media->collection_name . '/' . $media->id . '/';
22
    }
23
24
    /**
25
     * Get the path for conversions of the given media, relative to the root storage path.
26
     *
27
     * @param Media $media
28
     *
29
     * @return string
30
     */
31
    public function getPathForConversions(Media $media): string
32
    {
33
        return $this->getPath($media) . 'conversions/';
34
    }
35
36
    /**
37
     * Get the path for responsive images of the given media, relative to the root storage path.
38
     *
39
     * @param Media $media
40
     *
41
     * @return string
42
     */
43
    public function getPathForResponsiveImages(Media $media): string
44
    {
45
        return $this->getPath($media) . 'conversions/';
46
    }
47
}
48