< Summary

Information
Class: MyNet.Text.Redaction.RegexTextRedactor
Assembly: MyNet.Text
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Text/Redaction/RegexTextRedactor.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 28
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Apply(...)100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Text/Redaction/RegexTextRedactor.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="RegexTextRedactor.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.Globalization;
 9using System.Text.RegularExpressions;
 10
 11namespace MyNet.Text.Redaction;
 12
 13/// <summary>
 14/// Redacts text parts matching a regular expression.
 15/// </summary>
 16public sealed class RegexTextRedactor(Regex pattern, string replacement = "***") : ITextRedactorTransform
 17{
 18    /// <inheritdoc/>
 19    public string Apply(string input, CultureInfo culture)
 20    {
 1221        ArgumentNullException.ThrowIfNull(input);
 1222        ArgumentNullException.ThrowIfNull(culture);
 1223        ArgumentNullException.ThrowIfNull(pattern);
 24
 1225        return pattern.Replace(input, replacement);
 26    }
 27}
 28