InputEntry   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 59
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A toDMN() 0 15 3
A __construct() 0 4 1
A getExpressionLanguage() 0 3 1
A getExpression() 0 3 1
1
<?php
2
3
namespace SteffenBrand\DmnDecisionTables\Model;
4
5
use SteffenBrand\DmnDecisionTables\Constant\ExpressionLanguage;
6
7
/**
8
 * Class InputEntry
9
 * @package SteffenBrand\DmnDecisionTables\Model
10
 */
11
class InputEntry implements DmnConvertibleInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    private $expression;
17
18
    /**
19
     * @var string
20
     */
21
    private $expressionLanguage;
22
23
    /**
24
     * InputEntry constructor.
25
     * @param string $expression
26
     * @param string $expressionLanguage
27
     */
28
    public function __construct($expression, $expressionLanguage = ExpressionLanguage::FEEL_LANGUAGE)
29
    {
30
        $this->expression = $expression;
31
        $this->expressionLanguage = $expressionLanguage;
32
    }
33
34
    /**
35
     * Returns an XML representation of an input entry.
36
     *
37
     * @return string
38
     */
39
    public function toDMN()
40
    {
41
        $xml = '';
42
43
        if (isset($this->expression) === false || trim($this->expression) === '') {
44
            $xml .=
45
                '<inputEntry id="' . uniqid('inputEntry') . '"><text/></inputEntry>';
46
        } else {
47
            $xml .=
48
                '<inputEntry id="' . uniqid('inputEntry') . '" expressionLanguage="' . $this->expressionLanguage . '">' .
49
                    '<text><![CDATA[' . $this->expression . ']]></text>' .
50
                '</inputEntry>';
51
        }
52
53
        return $xml;
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getExpression()
60
    {
61
        return $this->expression;
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    public function getExpressionLanguage()
68
    {
69
        return $this->expressionLanguage;
70
    }
71
}