Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| Assets | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| image | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| file | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray\Assets; |
| 6 | |
| 7 | use Celemas\Core\Request; |
| 8 | use Cosray\Config; |
| 9 | use Cosray\Util\Path; |
| 10 | |
| 11 | class Assets |
| 12 | { |
| 13 | public readonly string $publicDir; |
| 14 | public readonly string $assetsDir; |
| 15 | public readonly string $cacheDir; |
| 16 | |
| 17 | public function __construct( |
| 18 | protected readonly Request $request, |
| 19 | protected readonly Config $config, |
| 20 | ) { |
| 21 | $this->publicDir = rtrim(realpath($config->path->public), '\\/'); |
| 22 | |
| 23 | $this->assetsDir = Path::inside($this->publicDir, $config->path->assets); |
| 24 | $this->cacheDir = Path::inside($this->publicDir, $config->path->cache); |
| 25 | } |
| 26 | |
| 27 | public function image(string $path): Image |
| 28 | { |
| 29 | return new Image($this->request, $this, $path); |
| 30 | } |
| 31 | |
| 32 | public function file(string $path): File |
| 33 | { |
| 34 | return new File($this->request, $this, $path); |
| 35 | } |
| 36 | } |