<?php

declare(strict_types=1);

namespace App\Services;

use App\Models\Configuration;

class ConfigurationService
{
    private Configuration $configModel;

    public function __construct()
    {
        $this->configModel = new Configuration();
    }

    public function getAll(): array
    {
        return $this->configModel->getAll();
    }

    public function findByKey(string $key): ?array
    {
        return $this->configModel->findByKey($key);
    }

    public function update(string $key, ?string $value, int $updatedBy): array
    {
        $this->configModel->set($key, $value, $updatedBy);
        $config = $this->configModel->findByKey($key);
        return $config ?? [];
    }
}
