<?php
namespace boru\ai\Config;

class ConfigLoader
{
    public static function fromArray(array $data)
    {
        return new Config($data);
    }

    public static function fromPhpFile($path)
    {
        if (!file_exists($path)) {
            throw new \InvalidArgumentException('Config PHP file not found: ' . $path);
        }

        $data = require $path;
        if (!is_array($data)) {
            throw new \RuntimeException('Config PHP file must return an array: ' . $path);
        }

        return new Config($data);
    }

    public static function fromJsonFile($path)
    {
        if (!file_exists($path)) {
            throw new \InvalidArgumentException('Config JSON file not found: ' . $path);
        }

        $json = file_get_contents($path);
        $data = json_decode($json, true);
        if (!is_array($data)) {
            throw new \RuntimeException('Config JSON file did not decode to an array: ' . $path);
        }

        return new Config($data);
    }
}
