Completed
Branch master (f94168)
by Steffen
03:41 queued 01:40
created

OutputEntry   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 59
loc 59
rs 10
c 1
b 0
f 1
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A toDMN() 15 15 3
A getExpression() 3 3 1
A getExpressionLanguage() 3 3 1
A __construct() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}