BasePathGenerator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

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