< Summary

Information
Class: Allyaria.Theming.StyleTypes.StyleLineBreak
Assembly: Allyaria.Theming
File(s): /home/runner/work/allyaria/allyaria/src/Allyaria.Theming/StyleTypes/StyleLineBreak.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 98
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/StyleLineBreak.cs

#LineLine coverage
 1namespace Allyaria.Theming.StyleTypes;
 2
 3/// <summary>
 4/// Represents a CSS <c>line-break</c> value within the Allyaria theming system. Provides a strongly typed wrapper for
 5/// controlling line-breaking behavior for text content.
 6/// </summary>
 7public sealed record StyleLineBreak : StyleValueBase
 8{
 9    /// <summary>
 10    /// Initializes a new instance of the <see cref="StyleLineBreak" /> record using the specified <see cref="Kind" /> v
 11    /// </summary>
 12    /// <param name="kind">The line-breaking behavior kind to represent.</param>
 13    public StyleLineBreak(Kind kind)
 3614        : base(value: kind.GetDescription()) { }
 15
 16    /// <summary>Defines the supported CSS <c>line-break</c> property values.</summary>
 17    public enum Kind
 18    {
 19        /// <summary>
 20        /// Allows unrestrained line breaks between any two characters for maximum flexibility. Useful for text with lon
 21        /// URLs.
 22        /// </summary>
 23        [Description(description: "anywhere")]
 24        Anywhere,
 25
 26        /// <summary>Uses the default line-breaking rules based on the document’s language and script.</summary>
 27        [Description(description: "auto")]
 28        Auto,
 29
 30        /// <summary>
 31        /// Provides looser line-breaking rules that may allow additional break opportunities, often used for East Asian
 32        /// improve readability.
 33        /// </summary>
 34        [Description(description: "loose")]
 35        Loose,
 36
 37        /// <summary>Applies standard line-breaking rules following the language’s usual behavior.</summary>
 38        [Description(description: "normal")]
 39        Normal,
 40
 41        /// <summary>Uses the most restrictive line-breaking rules, allowing breaks only where absolutely necessary.</su
 42        [Description(description: "strict")]
 43        Strict
 44    }
 45
 46    /// <summary>
 47    /// Parses a string representation of a CSS <c>line-break</c> value into a <see cref="StyleLineBreak" /> instance.
 48    /// </summary>
 49    /// <param name="value">The string representation of the line-break value.</param>
 50    /// <returns>A new <see cref="StyleLineBreak" /> instance representing the parsed value.</returns>
 51    /// <exception cref="AryArgumentException">
 52    /// Thrown when the provided <paramref name="value" /> does not correspond to a valid <see cref="Kind" />.
 53    /// </exception>
 54    public static StyleLineBreak Parse(string? value)
 1255        => value.TryParseEnum<Kind>(result: out var kind)
 1256            ? new StyleLineBreak(kind: kind)
 1257            : throw new AryArgumentException(message: $"Invalid style: {value}", argName: nameof(value));
 58
 59    /// <summary>Attempts to parse a string into a <see cref="StyleLineBreak" /> instance.</summary>
 60    /// <param name="value">The string representation of the line-break value to parse.</param>
 61    /// <param name="result">
 62    /// When this method returns, contains the parsed <see cref="StyleLineBreak" /> instance or <see langword="null" /> 
 63    /// parsing failed.
 64    /// </param>
 65    /// <returns><see langword="true" /> if parsing succeeded; otherwise, <see langword="false" />.</returns>
 66    public static bool TryParse(string? value, out StyleLineBreak? result)
 67    {
 68        try
 69        {
 370            result = Parse(value: value);
 71
 172            return true;
 73        }
 274        catch
 75        {
 276            result = null;
 77
 278            return false;
 79        }
 380    }
 81
 82    /// <summary>Implicitly converts a string into a <see cref="StyleLineBreak" /> instance.</summary>
 83    /// <param name="value">The string representation of the line-break value.</param>
 84    /// <returns>A <see cref="StyleLineBreak" /> instance representing the provided value.</returns>
 85    /// <exception cref="AryArgumentException">
 86    /// Thrown when the provided string cannot be parsed into a valid
 87    /// <see cref="Kind" />.
 88    /// </exception>
 289    public static implicit operator StyleLineBreak(string? value) => Parse(value: value);
 90
 91    /// <summary>Implicitly converts a <see cref="StyleLineBreak" /> instance to its string representation.</summary>
 92    /// <param name="value">The <see cref="StyleLineBreak" /> instance to convert.</param>
 93    /// <returns>
 94    /// The underlying CSS <c>line-break</c> string value, or an empty string if <paramref name="value" /> is
 95    /// <see langword="null" />.
 96    /// </returns>
 297    public static implicit operator string(StyleLineBreak? value) => (value?.Value).OrDefaultIfEmpty();
 98}