<?php

namespace Sitecake\Http;

/**
 * Simple key/value bag — replaces Symfony's ParameterBag for $request->query / $request->request / $request->files.
 */
class ParameterBag
{
    protected array $params;

    public function __construct(array $params = [])
    {
        $this->params = $params;
    }

    public function get(string $key, $default = null)
    {
        return $this->params[$key] ?? $default;
    }

    public function has(string $key): bool
    {
        return array_key_exists($key, $this->params);
    }

    public function all(): array
    {
        return $this->params;
    }

    public function set(string $key, $value): void
    {
        $this->params[$key] = $value;
    }

    public function remove(string $key): void
    {
        unset($this->params[$key]);
    }
}
