<?php
class LangController extends Controller
{
    public function switchLang(Request $request): void
    {
        $code = $request->routeParam('code');
        if (in_array($code, ['en', 'ar'])) {
            Lang::set($code);
        }
        $referer = $_SERVER['HTTP_REFERER'] ?? '/dashboard';
        Response::redirect($referer);
    }
}