< Summary

Information
Class: TeleFlow.Telegram.Internal.Handlers.TelegramRouteMatcher
Assembly: TeleFlow.Framework
File(s): /_/src/TeleFlow.Framework/Internal/Handlers/TelegramRouteMatcher.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 33
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Create(...)100%66100%

File(s)

/_/src/TeleFlow.Framework/Internal/Handlers/TelegramRouteMatcher.cs

#LineLine coverage
 1using System.Text.RegularExpressions;
 2
 3namespace TeleFlow.Telegram.Internal.Handlers;
 4
 5internal sealed class TelegramRouteMatcher
 6{
 7    private TelegramRouteMatcher(Regex? regex)
 8    {
 9        Regex = regex;
 115210    }
 11
 12    public Regex? Regex { get; }
 13
 14    public static TelegramRouteMatcher Create(
 15        TelegramRouteKind routeKind,
 16        string? pattern,
 17        bool ignoreCase)
 18    {
 115219        if (string.IsNullOrWhiteSpace(pattern))
 20        {
 59521            return new TelegramRouteMatcher(regex: null);
 22        }
 23
 55724        return routeKind switch
 55725        {
 55726            TelegramRouteKind.TextTemplate or TelegramRouteKind.CommandTemplate =>
 10027                new TelegramRouteMatcher(TelegramTemplateRouteParser.BuildRegex(pattern, ignoreCase)),
 55728            TelegramRouteKind.TextRegex or TelegramRouteKind.CommandRegex =>
 729                new TelegramRouteMatcher(new Regex(pattern, TelegramTemplateRouteParser.GetRegexOptions(ignoreCase))),
 45030            _ => new TelegramRouteMatcher(regex: null)
 55731        };
 32    }
 33}