Completed
Push — issue-37 ( 46b1e6...b187aa )
by Fèvre
04:23
created

XetaravelPathGenerator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 34
c 0
b 0
f 0
rs 10

3 Methods

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