<?php

declare(strict_types=1);

namespace App\Core\Middleware;

use App\Core\Request;
use App\Core\Csrf;

final class CsrfMiddleware implements MiddlewareInterface
{
    public function handle(callable $next): mixed
    {
        if (Request::method() === 'POST') {
            Csrf::verify();
        }

        return $next();
    }
}
