<?php

declare(strict_types=1);

class Request
{
    public static function json(): array
    {
        $raw = file_get_contents('php://input');
        $data = json_decode($raw, true);
        return is_array($data) ? $data : [];
    }

    public static function bearerToken(): ?string
    {
        $header = $_SERVER['HTTP_AUTHORIZATION'] ?? ($_SERVER['Authorization'] ?? '');

        if (stripos((string)$header, 'Bearer ') === 0) {
            return trim(substr((string)$header, 7));
        }

        return null;
    }
}
