< Summary

Information
Class: Elsa.Expressions.JavaScript.TypeDefinitions.Builders.FunctionDefinitionBuilder
Assembly: Elsa.Expressions.JavaScript
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/TypeDefinitions/Builders/FunctionDefinitionBuilder.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 8
Coverable lines: 8
Total lines: 43
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%210%
Name(...)100%210%
ReturnType(...)100%210%
Parameter(...)100%210%
BuildFunctionDefinition()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/TypeDefinitions/Builders/FunctionDefinitionBuilder.cs

#LineLine coverage
 1using Elsa.Expressions.JavaScript.TypeDefinitions.Models;
 2
 3namespace Elsa.Expressions.JavaScript.TypeDefinitions.Builders;
 4
 5/// <summary>
 6/// A builder API for building <see cref="FunctionDefinition"/>s.
 7/// </summary>
 8public class FunctionDefinitionBuilder
 9{
 010    private readonly FunctionDefinition _functionDefinition = new();
 11
 12    /// <summary>
 13    /// Set the name of the function.
 14    /// </summary>
 15    public FunctionDefinitionBuilder Name(string name)
 16    {
 017        _functionDefinition.Name = name;
 018        return this;
 19    }
 20
 21    /// <summary>
 22    /// Set the return type of the function.
 23    /// </summary>
 24    public FunctionDefinitionBuilder ReturnType(string? type)
 25    {
 026        _functionDefinition.ReturnType = type;
 027        return this;
 28    }
 29
 30    /// <summary>
 31    /// Add a parameter to the function.
 32    /// </summary>
 33    public FunctionDefinitionBuilder Parameter(string name, string? type, bool isOptional = false)
 34    {
 035        _functionDefinition.Parameters.Add(new (name, type, isOptional));
 036        return this;
 37    }
 38
 39    /// <summary>
 40    /// Build a <see cref="FunctionDefinition"/> using the collected information.
 41    /// </summary>
 042    public FunctionDefinition BuildFunctionDefinition() => new(_functionDefinition.Name, _functionDefinition.ReturnType,
 43}