Rewrite config to be seperate from path

This commit is contained in:
Tim
2025-05-18 23:52:22 +02:00
parent 15bd1c4031
commit 0fcbd87083
2 changed files with 20 additions and 9 deletions

View File

@ -2,12 +2,27 @@
require_once __DIR__ . '/functions.php';
readonly class config
readonly class homeConfig extends configReader
{
private const CONFIG_BASE_PATH = '.config';
public function __construct(
private string $name
string $name
)
{
parent::__construct(path(
getenv('HOME'),
self::CONFIG_BASE_PATH,
$name
));
}
}
readonly class configReader
{
public function __construct(
private string $path,
private string $fileName = 'config.php',
)
{
$this->init();
@ -30,17 +45,13 @@ readonly class config
{
return path(
$this->getConfigPath(),
'config.php'
$this->fileName
);
}
private function getConfigPath(): string
{
return path(
getenv('HOME'),
self::CONFIG_BASE_PATH,
$this->name
);
return $this->path;
}
private function init(): void