AzureBlobUrlGenerator::getTemporaryUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

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