< Summary

Information
Class: Pomodoro.Web.Models.TimerSettings
Assembly: Pomodoro.Web
File(s): /home/runner/work/Pomodoro/Pomodoro/src/Pomodoro.Web/Models/TimerSettings.cs
Line coverage
100%
Covered lines: 59
Uncovered lines: 0
Coverable lines: 59
Total lines: 148
Line coverage: 100%
Branch coverage
100%
Covered branches: 20
Total branches: 20
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%
get_PomodoroMinutes()100%11100%
set_PomodoroMinutes(...)100%11100%
get_ShortBreakMinutes()100%11100%
set_ShortBreakMinutes(...)100%11100%
get_LongBreakMinutes()100%11100%
set_LongBreakMinutes(...)100%11100%
GetDurationMinutes(...)100%44100%
GetDurationSeconds(...)100%11100%
get_SoundEnabled()100%11100%
get_NotificationsEnabled()100%11100%
get_AutoStartEnabled()100%11100%
get_AutoStartDelaySeconds()100%11100%
set_AutoStartDelaySeconds(...)100%11100%
Equals(...)100%1414100%
Equals(...)100%11100%
op_Equality(...)100%22100%
op_Inequality(...)100%11100%
GetHashCode()100%11100%
Clone()100%11100%

File(s)

/home/runner/work/Pomodoro/Pomodoro/src/Pomodoro.Web/Models/TimerSettings.cs

#LineLine coverage
 1namespace Pomodoro.Web.Models;
 2
 3/// <summary>
 4/// Configuration settings for timer durations and preferences
 5/// Values are automatically clamped to valid ranges on set.
 6/// </summary>
 7public class TimerSettings
 8{
 24639    private int _pomodoroMinutes = Constants.Timer.DefaultPomodoroMinutes;
 246310    private int _shortBreakMinutes = Constants.Timer.DefaultShortBreakMinutes;
 246311    private int _longBreakMinutes = Constants.Timer.DefaultLongBreakMinutes;
 12
 13    /// <summary>
 14    /// Pomodoro duration in minutes. Clamped to valid range.
 15    /// </summary>
 16    public int PomodoroMinutes
 17    {
 259818        get => _pomodoroMinutes;
 50819        set => _pomodoroMinutes = Math.Clamp(value, Constants.Timer.MinPomodoroMinutes, Constants.Timer.MaxPomodoroMinut
 20    }
 21
 22    /// <summary>
 23    /// Short break duration in minutes. Clamped to valid range.
 24    /// </summary>
 25    public int ShortBreakMinutes
 26    {
 225627        get => _shortBreakMinutes;
 48228        set => _shortBreakMinutes = Math.Clamp(value, Constants.Timer.MinBreakMinutes, Constants.Timer.MaxBreakMinutes);
 29    }
 30
 31    /// <summary>
 32    /// Long break duration in minutes. Clamped to valid range.
 33    /// </summary>
 34    public int LongBreakMinutes
 35    {
 223936        get => _longBreakMinutes;
 48037        set => _longBreakMinutes = Math.Clamp(value, Constants.Timer.MinBreakMinutes, Constants.Timer.MaxBreakMinutes);
 38    }
 39
 40    /// <summary>
 41    /// Gets the duration in minutes for the specified session type.
 42    /// Centralizes session duration logic to reduce code duplication.
 43    /// </summary>
 44    /// <param name="sessionType">The type of session</param>
 45    /// <returns>Duration in minutes for the session type</returns>
 16846    public int GetDurationMinutes(SessionType sessionType) => sessionType switch
 16847    {
 11748        SessionType.Pomodoro => PomodoroMinutes,
 2949        SessionType.ShortBreak => ShortBreakMinutes,
 2050        SessionType.LongBreak => LongBreakMinutes,
 251        _ => PomodoroMinutes
 16852    };
 53
 54    /// <summary>
 55    /// Gets the duration in seconds for the specified session type.
 56    /// Convenience method that converts minutes to seconds.
 57    /// </summary>
 58    /// <param name="sessionType">The type of session</param>
 59    /// <returns>Duration in seconds for the session type</returns>
 60    public int GetDurationSeconds(SessionType sessionType) =>
 13161        GetDurationMinutes(sessionType) * Constants.TimeConversion.SecondsPerMinute;
 62
 63    /// <summary>
 64    /// Whether sound notifications are enabled
 65    /// </summary>
 511466    public bool SoundEnabled { get; set; } = true;
 67
 68    /// <summary>
 69    /// Whether browser notifications are enabled
 70    /// </summary>
 499971    public bool NotificationsEnabled { get; set; } = true;
 72
 73    /// <summary>
 74    /// Whether to automatically start the next timer (pomodoro or break) after the current one completes
 75    /// </summary>
 517876    public bool AutoStartEnabled { get; set; } = true;
 77
 246378    private int _autoStartDelaySeconds = Constants.Timer.DefaultAutoStartDelaySeconds;
 79
 80    /// <summary>
 81    /// Delay in seconds before auto-starting. Clamped to valid range (3-60 seconds).
 82    /// </summary>
 83    public int AutoStartDelaySeconds
 84    {
 203185        get => _autoStartDelaySeconds;
 55886        set => _autoStartDelaySeconds = Math.Clamp(value, Constants.Timer.MinAutoStartDelaySeconds, Constants.Timer.MaxA
 87    }
 88
 89    /// <summary>
 90    /// Compares this settings instance with another for equality
 91    /// </summary>
 92    public bool Equals(TimerSettings? other)
 57993    {
 74394        if (other is null) return false;
 41595        return PomodoroMinutes == other.PomodoroMinutes
 41596            && ShortBreakMinutes == other.ShortBreakMinutes
 41597            && LongBreakMinutes == other.LongBreakMinutes
 41598            && SoundEnabled == other.SoundEnabled
 41599            && NotificationsEnabled == other.NotificationsEnabled
 415100            && AutoStartEnabled == other.AutoStartEnabled
 415101            && AutoStartDelaySeconds == other.AutoStartDelaySeconds;
 579102    }
 103
 104    /// <inheritdoc/>
 3105    public override bool Equals(object? obj) => Equals(obj as TimerSettings);
 106
 107    /// <summary>
 108    /// Equality operator for comparing two TimerSettings instances
 109    /// </summary>
 110    public static bool operator ==(TimerSettings? left, TimerSettings? right)
 510111    {
 635112        if (left is null) return right is null;
 385113        return left.Equals(right);
 510114    }
 115
 116    /// <summary>
 117    /// Inequality operator for comparing two TimerSettings instances
 118    /// </summary>
 119    public static bool operator !=(TimerSettings? left, TimerSettings? right)
 419120    {
 419121        return !(left == right);
 419122    }
 123
 124    /// <inheritdoc/>
 9125    public override int GetHashCode() => HashCode.Combine(
 9126        PomodoroMinutes,
 9127        ShortBreakMinutes,
 9128        LongBreakMinutes,
 9129        SoundEnabled,
 9130        NotificationsEnabled,
 9131        AutoStartEnabled,
 9132        AutoStartDelaySeconds);
 133
 134    /// <summary>
 135    /// Creates a deep copy of this settings instance
 136    /// </summary>
 137    /// <returns>A new TimerSettings instance with the same values</returns>
 292138    public TimerSettings Clone() => new()
 292139    {
 292140        PomodoroMinutes = PomodoroMinutes,
 292141        ShortBreakMinutes = ShortBreakMinutes,
 292142        LongBreakMinutes = LongBreakMinutes,
 292143        SoundEnabled = SoundEnabled,
 292144        NotificationsEnabled = NotificationsEnabled,
 292145        AutoStartEnabled = AutoStartEnabled,
 292146        AutoStartDelaySeconds = AutoStartDelaySeconds
 292147    };
 148}