Passed
Push — master ( a9e4c3...f94168 )
by Steffen
02:00
created

InputEntry::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 4
loc 4
rs 10
c 1
b 0
f 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 View Code Duplication
class InputEntry implements DmnConvertibleInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
}