Passed
Push — master ( df324d...7773d7 )
by Caen
03:06 queued 14s
created

AssetService   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A version() 0 3 1
A cdnLink() 0 3 1
A constructCdnPath() 0 3 1
A hasMediaFile() 0 3 1
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
    public function constructCdnPath(string $file): string
26
    {
27
        return 'https://cdn.jsdelivr.net/npm/hydefront@'.$this->version().'/dist/'.$file;
28
    }
29
30
    /**
31
     * Alias for constructCdnPath.
32
     */
33
    public function cdnLink(string $file): string
34
    {
35
        return $this->constructCdnPath($file);
36
    }
37
38
    public function hasMediaFile(string $file): bool
39
    {
40
        return file_exists(Hyde::path('_media').'/'.$file);
41
    }
42
}
43