*/ public static function json(): array { $payload = json_decode((string) file_get_contents('php://input'), true); if (!is_array($payload)) { JsonResponse::send(400, ['error' => 'Corps JSON invalide.']); } return $payload; } /** * Impose le verbe HTTP attendu (typiquement « POST » pour un endpoint mutant). */ public static function requireMethod(string $method): void { if (strtoupper($_SERVER['REQUEST_METHOD'] ?? 'GET') !== strtoupper($method)) { JsonResponse::send(405, ['error' => 'Méthode non autorisée.']); } } }