Completed
Push — master ( d2e6ed...f00d96 )
by Alex
10:33
created

TValueTermType::getReferenceType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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\Groups\TFacetAttributesTrait;
8
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TQualifiedNameTrait;
9
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSimpleIdentifierTrait;
10
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TWrappedFunctionTypeTrait;
11
12
/**
13
 * Class representing TValueTermType
14
 *
15
 *
16
 * XSD Type: TValueTerm
17
 */
18
class TValueTermType extends IsOK
19
{
20
    use TFacetAttributesTrait,
21
        GExpressionTrait,
22
        TQualifiedNameTrait,
23
        TSimpleIdentifierTrait,
24
        TWrappedFunctionReturnTrait;
25
26
    public function __construct()
27
    {
28
        $this->gExpressionMaximum = 1;
29
        $this->gExpressionMinimum = 1;
30
    }
31
    /**
32
     * @property string $name
33
     */
34
    private $name = null;
35
36
    /**
37
     * @property string $type
38
     */
39
    private $type = null;
40
41
    /**
42
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType $documentation
43
     */
44
    private $documentation = null;
45
46
    /**
47
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType
48
     */
49
    private $collectionType = null;
50
51
    /**
52
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType
53
     */
54
    private $referenceType = null;
55
56
    /**
57
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType
58
     */
59
    private $rowType = null;
60
61
    /**
62
     * Gets as name
63
     *
64
     * @return string
65
     */
66
    public function getName()
67
    {
68
        return $this->name;
69
    }
70
71
    /**
72
     * Sets a new name
73
     *
74
     * @param string $name
75
     * @return self
76
     */
77
    public function setName($name)
78
    {
79
        if (!$this->isTSimpleIdentifierValid($name)) {
80
            $msg = "Name must be a valid TSimpleIdentifier";
81
            throw new \InvalidArgumentException($msg);
82
        }
83
        $this->name = $name;
84
        return $this;
85
    }
86
87
    /**
88
     * Gets as type
89
     *
90
     * @return string
91
     */
92
    public function getType()
93
    {
94
        return $this->type;
95
    }
96
97
    /**
98
     * Sets a new type
99
     *
100
     * @param string $type
101
     * @return self
102
     */
103
    public function setType($type)
104
    {
105
        if (null != $type && !$this->isTWrappedFunctionTypeValid($type)) {
106
            $msg = "Type must be a valid TWrappedFunctionType";
107
            throw new \InvalidArgumentException($msg);
108
        }
109
        $this->type = $type;
110
        return $this;
111
    }
112
113
    /**
114
     * Gets as documentation
115
     *
116
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType
117
     */
118
    public function getDocumentation()
119
    {
120
        return $this->documentation;
121
    }
122
123
    /**
124
     * Sets a new documentation
125
     *
126
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType $documentation
127
     * @return self
128
     */
129 View Code Duplication
    public function setDocumentation(TDocumentationType $documentation)
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...
130
    {
131
        $msg = null;
132
        if (!$documentation->isOK($msg)) {
133
            throw new \InvalidArgumentException($msg);
134
        }
135
        $this->documentation = $documentation;
136
        return $this;
137
    }
138
139
    /**
140
     * Gets as collectionType
141
     *
142
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType
143
     */
144
    public function getCollectionType()
145
    {
146
        return $this->collectionType;
147
    }
148
149
    /**
150
     * Sets a new collectionType
151
     *
152
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType
153
     * @return self
154
     */
155
    public function setCollectionType(TCollectionTypeType $collectionType)
156
    {
157
        $msg = null;
158
        if (!$collectionType->isOK($msg)) {
159
            throw new \InvalidArgumentException($msg);
160
        }
161
        $this->collectionType = $collectionType;
162
        return $this;
163
    }
164
165
    /**
166
     * Gets as referenceType
167
     *
168
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType
169
     */
170
    public function getReferenceType()
171
    {
172
        return $this->referenceType;
173
    }
174
175
    /**
176
     * Sets a new referenceType
177
     *
178
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType
179
     * @return self
180
     */
181
    public function setReferenceType(TReferenceTypeType $referenceType)
182
    {
183
        $msg = null;
184
        if (!$referenceType->isOK($msg)) {
185
            throw new \InvalidArgumentException($msg);
186
        }
187
        $this->referenceType = $referenceType;
188
        return $this;
189
    }
190
191
    /**
192
     * Adds as property
193
     *
194
     * @return self
195
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType $property
196
     */
197
    public function addToRowType(TPropertyType $property)
198
    {
199
        $msg = null;
200
        if (!$property->isOK($msg)) {
201
            throw new \InvalidArgumentException($msg);
202
        }
203
        $this->rowType[] = $property;
204
        return $this;
205
    }
206
207
    /**
208
     * isset rowType
209
     *
210
     * @param scalar $index
211
     * @return boolean
212
     */
213
    public function issetRowType($index)
214
    {
215
        return isset($this->rowType[$index]);
216
    }
217
218
    /**
219
     * unset rowType
220
     *
221
     * @param scalar $index
222
     * @return void
223
     */
224
    public function unsetRowType($index)
225
    {
226
        unset($this->rowType[$index]);
227
    }
228
229
    /**
230
     * Gets as rowType
231
     *
232
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[]
233
     */
234
    public function getRowType()
235
    {
236
        return $this->rowType;
237
    }
238
239
    /**
240
     * Sets a new rowType
241
     *
242
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType
243
     * @return self
244
     */
245
    public function setRowType(array $rowType)
246
    {
247
        if (!$this->isValidArrayOK(
248
            $rowType,
249
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType',
250
            $msg
251
        )) {
252
            throw new \InvalidArgumentException($msg);
253
        }
254
        $this->rowType = $rowType;
255
        return $this;
256
    }
257
258
    public function isOK(&$msg = null)
259
    {
260
        if (!$this->isTSimpleIdentifierValid($this->name)) {
261
            $msg = "Name must be a valid TSimpleIdentifier";
262
            return false;
263
        }
264
        if (null != $this->type && !$this->isTWrappedFunctionTypeValid($this->type)) {
265
            $msg = "Type must be a valid TWrappedFunctionType";
266
            return false;
267
        }
268
269
        if (!$this->isObjectNullOrType(
270
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType',
271
            $this->documentation,
272
            $msg
273
        )) {
274
            return false;
275
        }
276
        if (!$this->isObjectNullOrType(
277
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType',
278
            $this->collectionType,
279
            $msg
280
        )) {
281
            return false;
282
        }
283
        if (!$this->isObjectNullOrType(
284
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType',
285
            $this->referenceType,
286
            $msg
287
        )) {
288
            return false;
289
        }
290
        if (!$this->isValidArrayOK(
291
            $this->rowType,
292
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType',
293
            $msg
294
        )) {
295
            return false;
296
        }
297
298
        $count = (isset($this->collectionType) ? 1 : 0)
299
                 + (isset($this->referenceType) ? 1 : 0)
300
                 + (isset($this->documentation) ? 1 : 0)
301
                 + (0 < count($this->rowType) ? 1 : 0);
302
        if (1 < $count) {
303
            $msg = "At most one of documentation, collection type, reference type and row type can be set/nonempty";
304
            return false;
305
        }
306
307
        if (!$this->isTFacetAttributesTraitValid($msg)) {
308
            return false;
309
        }
310
        return true;
311
    }
312
}
313