Passed
Push — master ( 143625...0aa694 )
by Alex
03:46
created

TValueTermReferenceExpressionType   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 80
Duplicated Lines 20 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 4
dl 16
loc 80
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getTerm() 0 4 1
A __construct() 0 5 1
A setTerm() 0 5 1
A getQualifier() 0 4 1
A setQualifier() 0 5 1
B isOK() 16 16 5

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 AlgoWeb\ODataMetadata\MetadataV3\edm;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\Groups\GExpressionTrait;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TQualifiedNameTrait;
8
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSimpleIdentifierTrait;
9
10
/**
11
 * Class representing TValueTermReferenceExpressionType
12
 *
13
 *
14
 * XSD Type: TValueTermReferenceExpression
15
 */
16
class TValueTermReferenceExpressionType extends IsOK
17
{
18
    use GExpressionTrait, TQualifiedNameTrait, TSimpleIdentifierTrait;
19
    /**
20
     * @property string $term
21
     */
22
    private $term = null;
23
24
    /**
25
     * @property string $qualifier
26
     */
27
    private $qualifier = null;
28
29
    /**
30
     * Gets as term
31
     *
32
     * @return string
33
     */
34
    public function getTerm()
35
    {
36
        return $this->term;
37
    }
38
39
    public function __construct()
40
    {
41
        $this->gExpressionMaximum = 1;
42
        $this->gExpressionMinimum = 1;
43
    }
44
45
    /**
46
     * Sets a new term
47
     *
48
     * @param string $term
49
     * @return self
50
     */
51
    public function setTerm($term)
52
    {
53
        $this->term = $term;
54
        return $this;
55
    }
56
57
    /**
58
     * Gets as qualifier
59
     *
60
     * @return string
61
     */
62
    public function getQualifier()
63
    {
64
        return $this->qualifier;
65
    }
66
67
    /**
68
     * Sets a new qualifier
69
     *
70
     * @param string $qualifier
71
     * @return self
72
     */
73
    public function setQualifier($qualifier)
74
    {
75
        $this->qualifier = $qualifier;
76
        return $this;
77
    }
78
79 View Code Duplication
    public function isOK(&$msg = null)
0 ignored issues
show
Duplication introduced by
This method 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...
80
    {
81
        if (!$this->isTQualifiedNameValid($this->term)) {
82
            $msg = "Term must be a valid TQualifiedName";
83
            return false;
84
        }
85
        if (null != $this->qualifier && !$this->isTSimpleIdentifierValid($this->qualifier)) {
86
            $msg = "Qualifier must be a valid TSimpleIdentifier";
87
            return false;
88
        }
89
        if (!$this->isGExpressionValid($msg)) {
90
            return false;
91
        }
92
93
        return true;
94
    }
95
}
96