first commit.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Toolbox;
|
||||
|
||||
/**
|
||||
* Fuente de paquetes en disco: `packages/<pkg>/<archivo>`.
|
||||
*/
|
||||
final class DirectorySource implements PackageSource
|
||||
{
|
||||
public function __construct(private readonly string $packagesDir)
|
||||
{
|
||||
}
|
||||
|
||||
public function baseDir(string $package): string
|
||||
{
|
||||
return rtrim($this->packagesDir, '/') . '/' . $package;
|
||||
}
|
||||
|
||||
public function read(string $package, string $file): ?string
|
||||
{
|
||||
$path = $this->baseDir($package) . '/' . ltrim($file, '/');
|
||||
|
||||
return is_file($path) ? (string) file_get_contents($path) : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user