XetaravelPathGenerator::getPathForConversions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 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