AzureBlobUrlGenerator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getUrl() 0 4 1
A getTemporaryUrl() 0 7 1
A getPath() 0 4 1
A getResponsiveImagesDirectoryUrl() 0 5 1
1
<?php
2
3
namespace DiamondByBOLD\FlysystemAzureBlobStorage\MediaLibrary\UrlGenerator;
4
5
use DateTimeInterface;
6
use Spatie\MediaLibrary\UrlGenerator\BaseUrlGenerator;
7
8
class AzureBlobUrlGenerator extends BaseUrlGenerator
9
{
10
    /**
11
     * Get the url for the profile of a media item.
12
     *
13
     * @return string
14
     */
15
    public function getUrl() : string
16
    {
17
        return config('medialibrary.azure.domain').'/'.$this->getPathRelativeToRoot();
18
    }
19
20
    /**
21
     * Get the temporary url for a media item.
22
     *
23
     * @param \DateTimeInterface $expiration
24
     * @param array $options
25
     *
26
     * @return string
27
     */
28
    public function getTemporaryUrl(DateTimeInterface $expiration, array $options = []): string
29
    {
30
        return $this
31
            ->filesystemManager
32
            ->disk($this->media->disk)
33
            ->temporaryUrl($this->getPath(), $expiration, $options);
34
    }
35
36
    /**
37
     * Get the url for the profile of a media item.
38
     *
39
     * @return string
40
     */
41
    public function getPath(): string
42
    {
43
        return $this->getPathRelativeToRoot();
44
    }
45
46
    /**
47
     * Get the url to the directory containing responsive images.
48
     *
49
     * @return string
50
     */
51
    public function getResponsiveImagesDirectoryUrl(): string
52
    {
53
        return config('medialibrary.azure.domain') . '/' .
54
            $this->pathGenerator->getPathForResponsiveImages($this->media);
55
    }
56
}
57