< Summary

Information
Class: Pomodoro.Web.Services.Formatters.StatCardFormatter
Assembly: Pomodoro.Web
File(s): /home/runner/work/Pomodoro/Pomodoro/src/Pomodoro.Web/Services/Formatters/StatCardFormatter.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 55
Line coverage: 100%
Branch coverage
100%
Covered branches: 10
Total branches: 10
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetFormattedValue(...)100%22100%
GetFormattedLabel(...)100%22100%
GetFormattedIcon(...)100%22100%
HasRequiredData(...)100%44100%

File(s)

/home/runner/work/Pomodoro/Pomodoro/src/Pomodoro.Web/Services/Formatters/StatCardFormatter.cs

#LineLine coverage
 1using Pomodoro.Web.Components.History;
 2
 3namespace Pomodoro.Web.Services.Formatters;
 4
 5/// <summary>
 6/// Service for formatting StatCard component data.
 7/// Extracts formatting logic from component to enable testable code with coverage tracking.
 8/// </summary>
 9public class StatCardFormatter
 10{
 11    /// <summary>
 12    /// Gets the formatted value for display.
 13    /// Returns "0" if value is empty or null.
 14    /// </summary>
 15    /// <param name="value">The value to format</param>
 16    /// <returns>Formatted value string</returns>
 17    public string GetFormattedValue(string? value)
 818    {
 819        return string.IsNullOrWhiteSpace(value) ? "0" : value;
 820    }
 21
 22    /// <summary>
 23    /// Gets the formatted label for display.
 24    /// Returns "N/A" if label is empty or null.
 25    /// </summary>
 26    /// <param name="label">The label to format</param>
 27    /// <returns>Formatted label string</returns>
 28    public string GetFormattedLabel(string? label)
 729    {
 730        return string.IsNullOrWhiteSpace(label) ? "N/A" : label;
 731    }
 32
 33    /// <summary>
 34    /// Gets the formatted icon for display.
 35    /// Returns default icon "📊" if icon is empty or null.
 36    /// </summary>
 37    /// <param name="icon">The icon to format</param>
 38    /// <returns>Formatted icon string</returns>
 39    public string GetFormattedIcon(string? icon)
 740    {
 741        return string.IsNullOrWhiteSpace(icon) ? "📊" : icon;
 742    }
 43
 44    /// <summary>
 45    /// Checks if the stat card has all required data.
 46    /// </summary>
 47    /// <param name="icon">The icon value</param>
 48    /// <param name="value">The value</param>
 49    /// <param name="label">The label</param>
 50    /// <returns>True if all required data is present</returns>
 51    public bool HasRequiredData(string? icon, string? value, string? label)
 1252    {
 1253        return !string.IsNullOrWhiteSpace(icon) && !string.IsNullOrWhiteSpace(value) && !string.IsNullOrWhiteSpace(label
 1254    }
 55}