Passed
Push — master ( 189420...0898fe )
by Alex
04:14
created

TComplexTypePropertyType::isOK()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 35
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 8.439
c 0
b 0
f 0
cc 6
eloc 24
nc 6
nop 1
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\MetadataV3\edm;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\IsOKTraits\IsOKToolboxTrait;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\Groups\TCommonPropertyAttributesTrait;
8
9
/**
10
 * Class representing TComplexTypePropertyType
11
 *
12
 *
13
 * XSD Type: TComplexTypeProperty
14
 */
15
class TComplexTypePropertyType extends IsOK
16
{
17
    use IsOKToolboxTrait, TCommonPropertyAttributesTrait;
18
19
    /**
20
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType[] $documentation
21
     */
22
    private $documentation = [];
23
24
    /**
25
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TValueAnnotationType[] $valueAnnotation
26
     */
27
    private $valueAnnotation = [];
28
29
    /**
30
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeAnnotationType[] $typeAnnotation
31
     */
32
    private $typeAnnotation = [];
33
34
    /**
35
     * Adds as documentation
36
     *
37
     * @return self
38
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType $documentation
39
     */
40
    public function addToDocumentation(TDocumentationType $documentation)
41
    {
42
        $this->documentation[] = $documentation;
43
        return $this;
44
    }
45
46
    /**
47
     * isset documentation
48
     *
49
     * @param scalar $index
50
     * @return boolean
51
     */
52
    public function issetDocumentation($index)
53
    {
54
        return isset($this->documentation[$index]);
55
    }
56
57
    /**
58
     * unset documentation
59
     *
60
     * @param scalar $index
61
     * @return void
62
     */
63
    public function unsetDocumentation($index)
64
    {
65
        unset($this->documentation[$index]);
66
    }
67
68
    /**
69
     * Gets as documentation
70
     *
71
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType[]
72
     */
73
    public function getDocumentation()
74
    {
75
        return $this->documentation;
76
    }
77
78
    /**
79
     * Sets a new documentation
80
     *
81
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType[] $documentation
82
     * @return self
83
     */
84
    public function setDocumentation(array $documentation)
85
    {
86
        $this->documentation = $documentation;
87
        return $this;
88
    }
89
90
    /**
91
     * Adds as valueAnnotation
92
     *
93
     * @return self
94
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TValueAnnotationType $valueAnnotation
95
     */
96
    public function addToValueAnnotation(TValueAnnotationType $valueAnnotation)
97
    {
98
        $this->valueAnnotation[] = $valueAnnotation;
99
        return $this;
100
    }
101
102
    /**
103
     * isset valueAnnotation
104
     *
105
     * @param scalar $index
106
     * @return boolean
107
     */
108
    public function issetValueAnnotation($index)
109
    {
110
        return isset($this->valueAnnotation[$index]);
111
    }
112
113
    /**
114
     * unset valueAnnotation
115
     *
116
     * @param scalar $index
117
     * @return void
118
     */
119
    public function unsetValueAnnotation($index)
120
    {
121
        unset($this->valueAnnotation[$index]);
122
    }
123
124
    /**
125
     * Gets as valueAnnotation
126
     *
127
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TValueAnnotationType[]
128
     */
129
    public function getValueAnnotation()
130
    {
131
        return $this->valueAnnotation;
132
    }
133
134
    /**
135
     * Sets a new valueAnnotation
136
     *
137
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TValueAnnotationType[] $valueAnnotation
138
     * @return self
139
     */
140
    public function setValueAnnotation(array $valueAnnotation)
141
    {
142
        $this->valueAnnotation = $valueAnnotation;
143
        return $this;
144
    }
145
146
    /**
147
     * Adds as typeAnnotation
148
     *
149
     * @return self
150
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeAnnotationType $typeAnnotation
151
     */
152
    public function addToTypeAnnotation(TTypeAnnotationType $typeAnnotation)
153
    {
154
        $this->typeAnnotation[] = $typeAnnotation;
155
        return $this;
156
    }
157
158
    /**
159
     * isset typeAnnotation
160
     *
161
     * @param scalar $index
162
     * @return boolean
163
     */
164
    public function issetTypeAnnotation($index)
165
    {
166
        return isset($this->typeAnnotation[$index]);
167
    }
168
169
    /**
170
     * unset typeAnnotation
171
     *
172
     * @param scalar $index
173
     * @return void
174
     */
175
    public function unsetTypeAnnotation($index)
176
    {
177
        unset($this->typeAnnotation[$index]);
178
    }
179
180
    /**
181
     * Gets as typeAnnotation
182
     *
183
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeAnnotationType[]
184
     */
185
    public function getTypeAnnotation()
186
    {
187
        return $this->typeAnnotation;
188
    }
189
190
    /**
191
     * Sets a new typeAnnotation
192
     *
193
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeAnnotationType[] $typeAnnotation
194
     * @return self
195
     */
196
    public function setTypeAnnotation(array $typeAnnotation)
197
    {
198
        $this->typeAnnotation = $typeAnnotation;
199
        return $this;
200
    }
201
202
    public function isOK(&$msg = null)
203
    {
204
        if (!$this->isValidArrayOK(
205
            $this->documentation,
206
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType',
207
            $msg
208
        )) {
209
            return false;
210
        }
211
        if (!$this->isValidArrayOK(
212
            $this->valueAnnotation,
213
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TValueAnnotationType',
214
            $msg
215
        )) {
216
            return false;
217
        }
218
        if (!$this->isValidArrayOK(
219
            $this->typeAnnotation,
220
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeAnnotationType',
221
            $msg
222
        )) {
223
            return false;
224
        }
225
        $count = count($this->documentation) + count($this->valueAnnotation) + count($this->typeAnnotation);
226
        if (0 == $count) {
227
            $msg = "At least one of documentation array, value annotation array and type annotation array must"
228
                   ."have at least one element";
229
            return false;
230
        }
231
        
232
        if (!$this->isTCommonPropertyAttributesValid($msg)) {
233
            return false;
234
        }
235
        return true;
236
    }
237
}
238