Completed
Push — master ( 279d4e...5d09e0 )
by Elf
02:49
created

AssetHelper   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 44
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFilesystem() 0 4 1
A getAssetUrl() 0 12 3
A getFilesystemDisk() 0 4 1
1
<?php
2
3
namespace ElfSundae\Laravel\Support\Traits;
4
5
use Illuminate\Support\Facades\Storage;
6
7
trait AssetHelper
8
{
9
    /**
10
     * Get Filesystem instance for the given identifier.
11
     *
12
     * @param  string|null  $identifier
13
     * @return \Illuminate\Contracts\Filesystem\Filesystem
14
     */
15
    protected function getFilesystem($identifier = null)
16
    {
17
        return Storage::disk($this->getFilesystemDisk($identifier));
18
    }
19
20
    /**
21
     * Get asset URL.
22
     *
23
     * @param  string  $path
24
     * @param  string|null  $identifier
25
     * @return string|null
26
     */
27
    protected function getAssetUrl($path, $identifier = null)
28
    {
29
        if (empty($path)) {
30
            return;
31
        }
32
33
        if (filter_var($path, FILTER_VALIDATE_URL) !== false) {
34
            return $path;
35
        }
36
37
        return asset_url($this->getFilesystem($identifier)->url($path));
38
    }
39
40
    /**
41
     * Get disk name for filesystem.
42
     *
43
     * @param  string|null  $identifier
44
     * @return string|null
45
     */
46
    protected function getFilesystemDisk($identifier = null)
1 ignored issue
show
Unused Code introduced by
The parameter $identifier is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
    {
48
        return 'public';
49
    }
50
}
51