Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Assets | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| add | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| dir | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray\Plugin; |
| 6 | |
| 7 | /** |
| 8 | * Plugin asset directories, keyed by plugin id. |
| 9 | * |
| 10 | * Files are served path-jailed under `{panel}/vendor/{id}/...`. |
| 11 | */ |
| 12 | final class Assets |
| 13 | { |
| 14 | /** @var array<string, string> */ |
| 15 | private array $dirs = []; |
| 16 | |
| 17 | public function add(string $id, string $dir): void |
| 18 | { |
| 19 | $this->dirs[$id] = rtrim($dir, '/'); |
| 20 | } |
| 21 | |
| 22 | public function dir(string $id): ?string |
| 23 | { |
| 24 | return $this->dirs[$id] ?? null; |
| 25 | } |
| 26 | } |