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

declare(strict_types=1);

namespace Drupal\{{ machine_name }}\Plugin\Filter;

{% apply sort_namespaces %}
  {% if configurable %}
use Drupal\Core\Form\FormStateInterface;
  {% endif %}
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\filter\Attribute\Filter;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
use Drupal\filter\Plugin\FilterInterface;
  {% if services %}
{{ di.use(services) }}
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
  {% endif %}
{% endapply %}

/**
 * @todo Add filter description here.
 */
#[Filter(
  id: '{{ plugin_id }}',
  title: new TranslatableMarkup('{{ plugin_label }}'),
  type: FilterInterface::{{ filter_type }},
{% if configurable %}
  settings: ['example' => 'foo'],
{% endif %}
)]
final class {{ class }} extends FilterBase {% if services %}implements ContainerFactoryPluginInterface {% endif %}{

{% if services %}
  /**
   * Constructs a new {{ class }} instance.
   */
  public function __construct(
    array $configuration,
    $plugin_id,
    $plugin_definition,
{{ di.signature(services) }}
  ) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): self {
    return new self(
      $configuration,
      $plugin_id,
      $plugin_definition,
{{ di.container(services) }}
    );
  }

{% endif %}
{% if configurable %}
  /**
   * {@inheritdoc}
   */
  public function settingsForm(array $form, FormStateInterface $form_state): array {
    $form['example'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Example'),
      '#default_value' => $this->settings['example'],
      '#description' => $this->t('Description of the setting.'),
    ];
    return $form;
  }

{% endif %}
  /**
   * {@inheritdoc}
   */
  public function process($text, $langcode): FilterProcessResult {
    // @todo Process text here.
{% if SUT_TEST %}
    $text = \str_replace('foo', 'bar', $text);
{% endif %}
    return new FilterProcessResult($text);
  }

  /**
   * {@inheritdoc}
   */
  public function tips($long = FALSE): string {
    return (string) $this->t('@todo Provide filter tips here.');
  }

}
