public static function commentLines()

in src/shipit/filter/ShipItConditionalLinesFilter.php [35:59]


  public static function commentLines(
    ShipItChangeset $changeset,
    ?string $path_regex,
    string $marker,
    string $comment_start,
    ?string $comment_end = null,
    bool $remove_content = false,
  ): ShipItChangeset {
    $pattern = '/^([-+ ]\s*)(\S.*) '.
      PHP\preg_quote($comment_start, '/').
      ' '.
      PHP\preg_quote($marker, '/').
      ($comment_end === null ? '' : (' '.PHP\preg_quote($comment_end, '/'))).
      '$/';

    $replacement = '\\1'.$comment_start.' '.$marker;
    if (!$remove_content) {
      $replacement .= ': \\2';
    }
    if ($comment_end !== null) {
      $replacement .= ' '.$comment_end;
    }

    return self::process($changeset, $path_regex, $pattern, $replacement);
  }