Passed
Push — master ( 26efa5...f69765 )
by Alex
03:20
created

TIncludeAnnotationsType   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 120
Duplicated Lines 8.33 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 15
c 1
b 0
f 0
lcom 1
cbo 3
dl 10
loc 120
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getTermNamespace() 0 4 1
A setTermNamespace() 0 5 1
A getQualifier() 0 4 1
A setQualifier() 0 5 1
A getTargetNamespace() 0 4 1
A setTargetNamespace() 0 5 1
D isOK() 10 34 9

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\MetadataV4\edmx;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\MetadataV4\edm\IsOKTraits\TNamespaceNameTrait;
7
use AlgoWeb\ODataMetadata\MetadataV4\edm\IsOKTraits\TSimpleIdentifierTrait;
8
9
/**
10
 * Class representing TIncludeAnnotationsType
11
 *
12
 *
13
 * XSD Type: TIncludeAnnotations
14
 */
15
class TIncludeAnnotationsType extends IsOK
16
{
17
    use TNamespaceNameTrait, TSimpleIdentifierTrait;
18
19
    /**
20
     * @property string $termNamespace
21
     */
22
    private $termNamespace = null;
23
24
    /**
25
     * @property string $qualifier
26
     */
27
    private $qualifier = null;
28
29
    /**
30
     * @property string $targetNamespace
31
     */
32
    private $targetNamespace = null;
33
34
    /**
35
     * Gets as termNamespace
36
     *
37
     * @return string
38
     */
39
    public function getTermNamespace()
40
    {
41
        return $this->termNamespace;
42
    }
43
44
    /**
45
     * Sets a new termNamespace
46
     *
47
     * @param string $termNamespace
48
     * @return self
49
     */
50
    public function setTermNamespace($termNamespace)
51
    {
52
        $this->termNamespace = $termNamespace;
53
        return $this;
54
    }
55
56
    /**
57
     * Gets as qualifier
58
     *
59
     * @return string
60
     */
61
    public function getQualifier()
62
    {
63
        return $this->qualifier;
64
    }
65
66
    /**
67
     * Sets a new qualifier
68
     *
69
     * @param string $qualifier
70
     * @return self
71
     */
72
    public function setQualifier($qualifier)
73
    {
74
        $this->qualifier = $qualifier;
75
        return $this;
76
    }
77
78
    /**
79
     * Gets as targetNamespace
80
     *
81
     * @return string
82
     */
83
    public function getTargetNamespace()
84
    {
85
        return $this->targetNamespace;
86
    }
87
88
    /**
89
     * Sets a new targetNamespace
90
     *
91
     * @param string $targetNamespace
92
     * @return self
93
     */
94
    public function setTargetNamespace($targetNamespace)
95
    {
96
        $this->targetNamespace = $targetNamespace;
97
        return $this;
98
    }
99
100
    protected function isOK(&$msg)
101
    {
102
        if (!$this->isStringNotNullOrEmpty($this->termNamespace)) {
103
            $msg = "Term namespace must be defined";
104
            return false;
105
        }
106
        if (!$this->isTNamespaceNameValid($this->termNamespace)) {
107
            $msg = "Term namespace must be a valid NameSpace";
108
            return false;
109
        }
110
111
112 View Code Duplication
        if (null != $this->qualifier) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
113
            if (!is_string($this->qualifier)) {
114
                $msg = "Qualifier must be either a string or null";
115
                return false;
116
            }
117
            if (!$this->isTSimpleIdentifierValid($this->qualifier)) {
118
                $msg = "Qualifier must be a valid TSimpleIdentifier";
119
                return false;
120
            }
121
        }
122
        if (null != $this->targetNamespace) {
123
            if (!is_string($this->targetNamespace)) {
124
                $msg = "TargetNamespace must be either a string or null";
125
                return false;
126
            }
127
            if (!$this->$this->IsTNamespaceNameValid($this->targetNamespace)) {
128
                $msg = "TargetNamespace must be a valid TNamespace";
129
                return false;
130
            }
131
        }
132
        return true;
133
    }
134
}
135