<?php

declare(strict_types=1);

namespace Drupal\flowdrop_workflow\Diagnostic\Mutation;

/**
 * Removes the node with the given id and cascades to its connected edges.
 *
 * The mutator removes every edge whose source or target is this node, so the
 * removal never leaves a dangling edge behind.
 */
final class RemoveNode implements WorkflowMutationInterface {

  /**
   * Constructs a RemoveNode mutation.
   *
   * @param string $nodeId
   *   The id of the node to remove.
   */
  public function __construct(
    public readonly string $nodeId,
  ) {}

  /**
   * {@inheritdoc}
   */
  public function summary(): string {
    return sprintf('Remove node "%s" and its connected edges.', $this->nodeId);
  }

}
