< Summary

Information
Line coverage
83%
Covered lines: 5
Uncovered lines: 1
Coverable lines: 6
Total lines: 55
Line coverage: 83.3%
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
Transform(...)100%11100%
Apply(...)100%11100%
Apply(...)100%11100%
Apply(...)100%210%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Text/Extensions/TransformExtensions.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="TransformExtensions.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.Linq;
 10
 11#pragma warning disable IDE0130 // Namespace does not match folder structure
 12namespace MyNet.Text;
 13#pragma warning restore IDE0130 // Namespace does not match folder structure
 14
 15public static class TransformExtensions
 16{
 17    extension(TextPipeline pipeline)
 18    {
 19        /// <summary>
 20        /// Transforms the text in the pipeline using the provided transformers. Transformations are applied in the prov
 21        /// </summary>
 22        /// <param name="transformers">The transformers to apply.</param>
 23        /// <returns>The transformed text.</returns>
 324        public string Transform(params ITextTransform[] transformers) => pipeline.Apply(transformers).Value;
 25
 26        /// <summary>
 27        /// Applies the provided transformers to the pipeline. Transformations are applied in the provided order.
 28        /// </summary>
 29        /// <param name="transformers">The transformers to apply.</param>
 30        /// <returns>The transformed TextPipeline instance.</returns>
 631        public TextPipeline Apply(params ITextTransform[] transformers) => transformers.Aggregate(pipeline, (current, tr
 32    }
 33
 34    extension(string input)
 35    {
 36        /// <summary>
 37        /// Transforms a string using the provided transformers. Transformations are applied in the provided order.
 38        /// </summary>
 39        public string Apply(CultureInfo culture, params ITextTransform[] transformers)
 40        {
 25241            ArgumentNullException.ThrowIfNull(input);
 25242            ArgumentNullException.ThrowIfNull(culture);
 43
 25244            return transformers.Aggregate(input, (current, transform) => transform.Apply(current, culture));
 45        }
 46
 47        /// <summary>
 48        /// Transforms a string using the provided transformers. Transformations are applied in the provided order. The 
 49        /// </summary>
 50        /// <param name="transformers">The transformers to apply.</param>
 51        /// <returns>The transformed string.</returns>
 052        public string Apply(params ITextTransform[] transformers) => input.Apply(CultureInfo.CurrentCulture, transformer
 53    }
 54}
 55