{% import '@lib/di.twig' as di %}
<?php

declare(strict_types=1);

namespace Drupal\{{ machine_name }};

{% apply sort_namespaces %}
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
  {% if services %}
{{ di.use(services) }}
  {% endif %}
{% endapply %}

/**
 * @todo Add a description for the middleware.
 */
final class {{ class }} implements HttpKernelInterface {
{% if services %}

  /**
   * Constructs {{ class|article }} object.
   */
  public function __construct(
{{ di.signature(services) }}
  ) {}
{% endif %}

  /**
   * {@inheritdoc}
   */
  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
    // @todo Modify the request here.
    $response = $this->httpKernel->handle($request, $type, $catch);
    // @todo Modify the response here.
{% if SUT_TEST %}
    $response->headers->set('x-middleware-handle-test', NULL);
{% endif %}
    return $response;
  }

}
