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

OutputEntry::toDMN()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 15
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 10
nc 2
nop 0
dl 15
loc 15
rs 9.4285
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 OutputEntry
9
 * @package SteffenBrand\DmnDecisionTables\Model
10
 */
11 View Code Duplication
class OutputEntry 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
     * OutputEntry constructor.
25
     * @param string $expression
26
     * @param string $expressionLanguage
27
     */
28
    public function __construct($expression, $expressionLanguage = ExpressionLanguage::JUEL_LANGUAGE)
29
    {
30
        $this->expression = $expression;
31
        $this->expressionLanguage = $expressionLanguage;
32
    }
33
34
    /**
35
     * Returns an XML representation of an output 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
                '<outputEntry id="' . uniqid('outputEntry') . '"><text/></outputEntry>';
46
        } else {
47
            $xml .=
48
                '<outputEntry id="' . uniqid('outputEntry') . '" expressionLanguage="' . $this->expressionLanguage . '">' .
49
                    '<text><![CDATA[' . $this->expression . ']]></text>' .
50
                '</outputEntry>';
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
}