Files
TVGuide/app/src/Config.php
T
2026-07-06 21:35:19 +02:00

39 lines
917 B
PHP

<?php
class Config
{
private array $config = [];
private array $channels = [];
public function __construct(
string $configFile,
string $channelsFile
) {
if (file_exists($configFile)) {
$this->config = json_decode(file_get_contents($configFile), true) ?? [];
}
if (file_exists($channelsFile)) {
$this->channels = json_decode(file_get_contents($channelsFile), true) ?? [];
}
}
public function get(string $key, mixed $default = null): mixed
{
return $this->config[$key] ?? $default;
}
public function getChannels(): array
{
return $this->channels;
}
public function saveChannels(array $channels): void
{
file_put_contents(
'/var/www/config/channels.json',
json_encode($channels, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
);
}
}