< Summary

Information
Class: MyNet.Globalization.Inflection.InflectionRule
Assembly: MyNet.Globalization
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Globalization/Inflection/InflectionRule.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 25
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

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

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Globalization/Inflection/InflectionRule.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="InflectionRule.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.Globalization.Inflection;
 10
 11/// <summary>
 12/// Represents a single inflection rule, consisting of a regular expression pattern and a replacement string. The rule c
 13/// </summary>
 14/// <param name="Regex">The regular expression pattern to match.</param>
 15/// <param name="Replacement">The replacement string to use when the pattern matches.</param>
 16public sealed record InflectionRule(Regex Regex, string Replacement)
 17{
 18    /// <summary>
 19    /// Applies the inflection rule to the specified word. If the regular expression pattern matches the word, it return
 20    /// </summary>
 21    /// <param name="word">The word to which the inflection rule will be applied.</param>
 22    /// <returns>The transformed word if the pattern matches; otherwise, null.</returns>
 14918123    public string? Apply(string word) => !Regex.IsMatch(word) ? null : Regex.Replace(word, Replacement);
 24}
 25

Methods/Properties

Apply(System.String)