<?php
declare(strict_types=1);

class Request {
    /**
     * @return array<string, mixed>
     */
    public static function getJson(): array {
        $json = file_get_contents('php://input');
        $data = json_decode($json, true) ?? [];
        
        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new RuntimeException('Invalid JSON payload');
        }
        
        return $data;
    }
    
    public static function getValue(string $key, mixed $default = null): mixed {
        return $_REQUEST[$key] ?? $default;
    }
}