< Summary

Information
Class: Allyaria.Theming.StyleTypes.StyleTextWrapStyle
Assembly: Allyaria.Theming
File(s): /home/runner/work/allyaria/allyaria/src/Allyaria.Theming/StyleTypes/StyleTextWrapStyle.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 97
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
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%
Parse(...)100%22100%
TryParse(...)100%11100%
op_Implicit(...)100%11100%
op_Implicit(...)100%22100%

File(s)

/home/runner/work/allyaria/allyaria/src/Allyaria.Theming/StyleTypes/StyleTextWrapStyle.cs

#LineLine coverage
 1namespace Allyaria.Theming.StyleTypes;
 2
 3/// <summary>
 4/// Represents a CSS <c>text-wrap-style</c> value within the Allyaria theming system. Provides a strongly typed wrapper 
 5/// defining how lines of text should wrap within a block container.
 6/// </summary>
 7public sealed record StyleTextWrapStyle : StyleValueBase
 8{
 9    /// <summary>
 10    /// Initializes a new instance of the <see cref="StyleTextWrapStyle" /> record using the specified <see cref="Kind" 
 11    /// value.
 12    /// </summary>
 13    /// <param name="kind">The text wrapping behavior to represent.</param>
 14    public StyleTextWrapStyle(Kind kind)
 3015        : base(value: kind.GetDescription()) { }
 16
 17    /// <summary>Defines the supported CSS <c>text-wrap-style</c> property values.</summary>
 18    public enum Kind
 19    {
 20        /// <summary>Uses the browser’s default line-breaking and wrapping rules for the text.</summary>
 21        [Description(description: "auto")]
 22        Auto,
 23
 24        /// <summary>
 25        /// Balances wrapped lines within a block, distributing text evenly across lines when possible. Useful for headi
 26        /// short multi-line text.
 27        /// </summary>
 28        [Description(description: "balance")]
 29        Balance,
 30
 31        /// <summary>
 32        /// Adjusts wrapping to produce visually pleasing text edges, potentially varying line lengths slightly to impro
 33        /// aesthetics.
 34        /// </summary>
 35        [Description(description: "pretty")]
 36        Pretty,
 37
 38        /// <summary>
 39        /// Maintains consistent line-breaking behavior for a stable layout even when content changes or is dynamically 
 40        /// </summary>
 41        [Description(description: "stable")]
 42        Stable
 43    }
 44
 45    /// <summary>
 46    /// Parses a string representation of a CSS <c>text-wrap-style</c> value into a <see cref="StyleTextWrapStyle" /> in
 47    /// </summary>
 48    /// <param name="value">The string representation of the text-wrap-style value.</param>
 49    /// <returns>A new <see cref="StyleTextWrapStyle" /> instance representing the parsed value.</returns>
 50    /// <exception cref="AryArgumentException">
 51    /// Thrown when the provided <paramref name="value" /> does not correspond to a valid <see cref="Kind" />.
 52    /// </exception>
 53    public static StyleTextWrapStyle Parse(string? value)
 1154        => value.TryParseEnum<Kind>(result: out var kind)
 1155            ? new StyleTextWrapStyle(kind: kind)
 1156            : throw new AryArgumentException(message: $"Invalid style: {value}", argName: nameof(value));
 57
 58    /// <summary>Attempts to parse a string into a <see cref="StyleTextWrapStyle" /> instance.</summary>
 59    /// <param name="value">The string representation of the text-wrap-style value to parse.</param>
 60    /// <param name="result">
 61    /// When this method returns, contains the parsed <see cref="StyleTextWrapStyle" /> instance or <see langword="null"
 62    /// parsing failed.
 63    /// </param>
 64    /// <returns><see langword="true" /> if parsing succeeded; otherwise, <see langword="false" />.</returns>
 65    public static bool TryParse(string? value, out StyleTextWrapStyle? result)
 66    {
 67        try
 68        {
 369            result = Parse(value: value);
 70
 171            return true;
 72        }
 273        catch
 74        {
 275            result = null;
 76
 277            return false;
 78        }
 379    }
 80
 81    /// <summary>Implicitly converts a string into a <see cref="StyleTextWrapStyle" /> instance.</summary>
 82    /// <param name="value">The string representation of the text-wrap-style value.</param>
 83    /// <returns>A <see cref="StyleTextWrapStyle" /> instance representing the provided value.</returns>
 84    /// <exception cref="AryArgumentException">
 85    /// Thrown when the provided string cannot be parsed into a valid
 86    /// <see cref="Kind" />.
 87    /// </exception>
 288    public static implicit operator StyleTextWrapStyle(string? value) => Parse(value: value);
 89
 90    /// <summary>Implicitly converts a <see cref="StyleTextWrapStyle" /> instance to its string representation.</summary
 91    /// <param name="value">The <see cref="StyleTextWrapStyle" /> instance to convert.</param>
 92    /// <returns>
 93    /// The underlying CSS <c>text-wrap-style</c> string value, or an empty string if <paramref name="value" /> is
 94    /// <see langword="null" />.
 95    /// </returns>
 296    public static implicit operator string(StyleTextWrapStyle? value) => (value?.Value).OrDefaultIfEmpty();
 97}