Passed
Push — master ( d2da49...fac384 )
by Alex
03:51
created

TEntityTypeType   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 207
Duplicated Lines 13.04 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 19
lcom 1
cbo 2
dl 27
loc 207
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A setName() 0 5 1
A getDocumentation() 0 4 1
A setDocumentation() 0 5 1
A addToKey() 0 5 1
A issetKey() 0 4 1
A unsetKey() 0 4 1
A getKey() 0 4 1
A setKey() 0 5 1
A addToProperty() 0 5 1
A issetProperty() 0 4 1
A unsetProperty() 0 4 1
A getProperty() 0 4 1
A setProperty() 0 5 1
B isOK() 27 27 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\ssdl;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TUndottedIdentifierTrait;
7
8
/**
9
 * Class representing TEntityTypeType
10
 *
11
 *
12
 * XSD Type: TEntityType
13
 */
14
class TEntityTypeType extends IsOK
15
{
16
    use TUndottedIdentifierTrait;
17
    /**
18
     * @property string $name
19
     */
20
    private $name = null;
21
22
    /**
23
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
24
     */
25
    private $documentation = null;
26
27
    /**
28
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType[] $key
29
     */
30
    private $key = [];
31
32
    /**
33
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TEntityPropertyType[] $property
34
     */
35
    private $property = [];
36
37
    /**
38
     * Gets as name
39
     *
40
     * @return string
41
     */
42
    public function getName()
43
    {
44
        return $this->name;
45
    }
46
47
    /**
48
     * Sets a new name
49
     *
50
     * @param string $name
51
     * @return self
52
     */
53
    public function setName($name)
54
    {
55
        $this->name = $name;
56
        return $this;
57
    }
58
59
    /**
60
     * Gets as documentation
61
     *
62
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType
63
     */
64
    public function getDocumentation()
65
    {
66
        return $this->documentation;
67
    }
68
69
    /**
70
     * Sets a new documentation
71
     *
72
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
73
     * @return self
74
     */
75
    public function setDocumentation(TDocumentationType $documentation)
76
    {
77
        $this->documentation = $documentation;
78
        return $this;
79
    }
80
81
    /**
82
     * Adds as propertyRef
83
     *
84
     * @return self
85
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType $propertyRef
86
     */
87
    public function addToKey(TPropertyRefType $propertyRef)
88
    {
89
        $this->key[] = $propertyRef;
90
        return $this;
91
    }
92
93
    /**
94
     * isset key
95
     *
96
     * @param scalar $index
97
     * @return boolean
98
     */
99
    public function issetKey($index)
100
    {
101
        return isset($this->key[$index]);
102
    }
103
104
    /**
105
     * unset key
106
     *
107
     * @param scalar $index
108
     * @return void
109
     */
110
    public function unsetKey($index)
111
    {
112
        unset($this->key[$index]);
113
    }
114
115
    /**
116
     * Gets as key
117
     *
118
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType[]
119
     */
120
    public function getKey()
121
    {
122
        return $this->key;
123
    }
124
125
    /**
126
     * Sets a new key
127
     *
128
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType[] $key
129
     * @return self
130
     */
131
    public function setKey(array $key)
132
    {
133
        $this->key = $key;
134
        return $this;
135
    }
136
137
    /**
138
     * Adds as property
139
     *
140
     * @return self
141
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TEntityPropertyType $property
142
     */
143
    public function addToProperty(TEntityPropertyType $property)
144
    {
145
        $this->property[] = $property;
146
        return $this;
147
    }
148
149
    /**
150
     * isset property
151
     *
152
     * @param scalar $index
153
     * @return boolean
154
     */
155
    public function issetProperty($index)
156
    {
157
        return isset($this->property[$index]);
158
    }
159
160
    /**
161
     * unset property
162
     *
163
     * @param scalar $index
164
     * @return void
165
     */
166
    public function unsetProperty($index)
167
    {
168
        unset($this->property[$index]);
169
    }
170
171
    /**
172
     * Gets as property
173
     *
174
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TEntityPropertyType[]
175
     */
176
    public function getProperty()
177
    {
178
        return $this->property;
179
    }
180
181
    /**
182
     * Sets a new property
183
     *
184
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TEntityPropertyType[] $property
185
     * @return self
186
     */
187
    public function setProperty(array $property)
188
    {
189
        $this->property = $property;
190
        return $this;
191
    }
192
193 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...
194
    {
195
        if (!$this->isStringNotNullOrEmpty($this->name)) {
196
            $msg = "Name cannot be null or empty";
197
            return false;
198
        }
199
        if (!$this->isObjectNullOrOK($this->documentation, $msg)) {
200
            return false;
201
        }
202
        if (!$this->isValidArrayOK(
203
            $this->key,
204
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType',
205
            $msg,
206
            1
207
        )) {
208
            return false;
209
        }
210
        if (!$this->isValidArrayOK(
211
            $this->property,
212
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TEntityPropertyType',
213
            $msg
214
        )) {
215
            return false;
216
        }
217
218
        return true;
219
    }
220
}
221