Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
| AssetService | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
| version | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| stylePath | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| scriptPath | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| constructCdnPath | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasMediaFile | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Hyde\Framework\Services; |
| 4 | |
| 5 | use Hyde\Framework\Contracts\AssetServiceContract; |
| 6 | use Hyde\Framework\Hyde; |
| 7 | |
| 8 | class AssetService implements AssetServiceContract |
| 9 | { |
| 10 | /** |
| 11 | * The default HydeFront version to load. |
| 12 | * |
| 13 | * @property string $version HydeFront SemVer Tag |
| 14 | */ |
| 15 | public string $version = 'v1.11'; |
| 16 | |
| 17 | public function version(): string |
| 18 | { |
| 19 | return $this->version; |
| 20 | } |
| 21 | |
| 22 | public function stylePath(): string |
| 23 | { |
| 24 | return $this->constructCdnPath('hyde.css'); |
| 25 | } |
| 26 | |
| 27 | public function scriptPath(): string |
| 28 | { |
| 29 | return $this->constructCdnPath('hyde.js'); |
| 30 | } |
| 31 | |
| 32 | public function constructCdnPath(string $file): string |
| 33 | { |
| 34 | return 'https://cdn.jsdelivr.net/npm/hydefront@'.$this->version().'/dist/'.$file; |
| 35 | } |
| 36 | |
| 37 | public function hasMediaFile(string $file): bool |
| 38 | { |
| 39 | return file_exists(Hyde::path('_media').'/'.$file); |
| 40 | } |
| 41 | } |