< Summary

Information
Class: MyNet.Text.Redaction.Redactor
Assembly: MyNet.Text
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Text/Redaction/Redactor.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 45
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
.cctor()100%11100%

File(s)

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

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="Redactor.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System.Text.RegularExpressions;
 8
 9namespace MyNet.Text.Redaction;
 10
 11/// <summary>
 12/// Provides common text redaction transforms.
 13/// </summary>
 14public static partial class Redactor
 15{
 16    /// <summary>
 17    /// Gets a generic redactor that preserves the first and last two characters.
 18    /// </summary>
 319    public static ITextRedactorTransform Generic { get; } = new FixedMaskTextRedactor(new() { ShowStart = 2, ShowEnd = 2
 20
 21    /// <summary>
 22    /// Gets an email redactor that preserves first character and domain suffix.
 23    /// </summary>
 324    public static ITextRedactorTransform Email { get; } = new RegexTextRedactor(EmailRegex());
 25
 26    /// <summary>
 27    /// Gets a phone redactor that masks all digits except the last two.
 28    /// </summary>
 329    public static ITextRedactorTransform Phone { get; } = new RegexTextRedactor(PhoneRegex(), "*");
 30
 31    /// <summary>
 32    /// Gets a card number redactor that masks all digits except the last four.
 33    /// </summary>
 334    public static ITextRedactorTransform CardNumber { get; } = new RegexTextRedactor(CardNumberRegex(), "*");
 35
 36    [GeneratedRegex("(?<=.).(?=[^@]*?@)|(?<=@.).(?=[^.]*\\.)", RegexOptions.Compiled)]
 37    private static partial Regex EmailRegex();
 38
 39    [GeneratedRegex(@"\d(?=(?:\D*\d){2})", RegexOptions.Compiled)]
 40    private static partial Regex PhoneRegex();
 41
 42    [GeneratedRegex(@"\d(?=(?:\D*\d){4})", RegexOptions.Compiled)]
 43    private static partial Regex CardNumberRegex();
 44}
 45

Methods/Properties

.cctor()