Passed
Push — master ( 6107a7...a6bdea )
by Caen
06:56 queued 02:42
created

AssetService::scriptPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Hyde\Framework\Services;
4
5
use Hyde\Framework\Contracts\AssetServiceContract;
6
use Hyde\Framework\Hyde;
7
8
/**
9
 * @see \Hyde\Framework\Facades\Asset
10
 */
11
class AssetService implements AssetServiceContract
12
{
13
    /**
14
     * The default HydeFront version to load.
15
     *
16
     * @property string $version HydeFront SemVer Tag
17
     */
18
    public string $version = 'v2.0';
19
20
    public function version(): string
21
    {
22
        return $this->version;
23
    }
24
25
    /**
26
     * @deprecated v0.50.x - Use cdnLink() instead.
27
     */
28
    public function stylePath(): string
29
    {
30
        return $this->constructCdnPath('hyde.css');
31
    }
32
33
    public function constructCdnPath(string $file): string
34
    {
35
        return 'https://cdn.jsdelivr.net/npm/hydefront@'.$this->version().'/dist/'.$file;
36
    }
37
38
    /**
39
     * Alias for constructCdnPath.
40
     *
41
     * @since 0.41.x
42
     */
43
    public function cdnLink(string $file): string
44
    {
45
        return $this->constructCdnPath($file);
46
    }
47
48
    public function hasMediaFile(string $file): bool
49
    {
50
        return file_exists(Hyde::path('_media').'/'.$file);
51
    }
52
}
53