Code Duplication    Length = 218-218 lines in 2 locations

src/MetadataV3/edm/TFunctionParameterType.php 1 location

@@ 17-234 (lines=218) @@
14
 *
15
 * XSD Type: TFunctionParameter
16
 */
17
class TFunctionParameterType extends IsOK
18
{
19
    use IsOKToolboxTrait, TFacetAttributesTrait, TSimpleIdentifierTrait, TWrappedFunctionReturnTypeTrait;
20
    /**
21
     * @property string $name
22
     */
23
    private $name = null;
24
25
    /**
26
     * @property string $type
27
     */
28
    private $type = null;
29
30
    /**
31
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType
32
     */
33
    private $collectionType = null;
34
35
    /**
36
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType
37
     */
38
    private $referenceType = null;
39
40
    /**
41
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType
42
     */
43
    private $rowType = [];
44
45
    /**
46
     * Gets as name
47
     *
48
     * @return string
49
     */
50
    public function getName()
51
    {
52
        return $this->name;
53
    }
54
55
    /**
56
     * Sets a new name
57
     *
58
     * @param string $name
59
     * @return self
60
     */
61
    public function setName($name)
62
    {
63
        $this->name = $name;
64
        return $this;
65
    }
66
67
    /**
68
     * Gets as type
69
     *
70
     * @return string
71
     */
72
    public function getType()
73
    {
74
        return $this->type;
75
    }
76
77
    /**
78
     * Sets a new type
79
     *
80
     * @param string $type
81
     * @return self
82
     */
83
    public function setType($type)
84
    {
85
        $this->type = $type;
86
        return $this;
87
    }
88
89
    /**
90
     * Gets as collectionType
91
     *
92
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType
93
     */
94
    public function getCollectionType()
95
    {
96
        return $this->collectionType;
97
    }
98
99
    /**
100
     * Sets a new collectionType
101
     *
102
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType
103
     * @return self
104
     */
105
    public function setCollectionType(TCollectionTypeType $collectionType)
106
    {
107
        $this->collectionType = $collectionType;
108
        return $this;
109
    }
110
111
    /**
112
     * Gets as referenceType
113
     *
114
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType
115
     */
116
    public function getReferenceType()
117
    {
118
        return $this->referenceType;
119
    }
120
121
    /**
122
     * Sets a new referenceType
123
     *
124
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType
125
     * @return self
126
     */
127
    public function setReferenceType(TReferenceTypeType $referenceType)
128
    {
129
        $this->referenceType = $referenceType;
130
        return $this;
131
    }
132
133
    /**
134
     * Adds as property
135
     *
136
     * @return self
137
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType $property
138
     */
139
    public function addToRowType(TPropertyType $property)
140
    {
141
        $this->rowType[] = $property;
142
        return $this;
143
    }
144
145
    /**
146
     * isset rowType
147
     *
148
     * @param scalar $index
149
     * @return boolean
150
     */
151
    public function issetRowType($index)
152
    {
153
        return isset($this->rowType[$index]);
154
    }
155
156
    /**
157
     * unset rowType
158
     *
159
     * @param scalar $index
160
     * @return void
161
     */
162
    public function unsetRowType($index)
163
    {
164
        unset($this->rowType[$index]);
165
    }
166
167
    /**
168
     * Gets as rowType
169
     *
170
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[]
171
     */
172
    public function getRowType()
173
    {
174
        return $this->rowType;
175
    }
176
177
    /**
178
     * Sets a new rowType
179
     *
180
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType
181
     * @return self
182
     */
183
    public function setRowType(array $rowType)
184
    {
185
        $this->rowType = $rowType;
186
        return $this;
187
    }
188
189
    public function isOK(&$msg = null)
190
    {
191
        if (!$this->isTSimpleIdentifierValid($this->name)) {
192
            $msg = "Name must be a valid TSimpleIdentifier";
193
            return false;
194
        }
195
        if (null != $this->type && !$this->isTWrappedFunctionTypeValid($this->type)) {
196
            $msg = "Type must be a valid TWrappedFunctionType";
197
            return false;
198
        }
199
        if (!$this->isTFacetAttributesTraitValid($msg)) {
200
            return false;
201
        }
202
        if (!$this->isObjectNullOrType(
203
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType',
204
            $this->collectionType,
205
            $msg
206
        )) {
207
            return false;
208
        }
209
        if (!$this->isObjectNullOrType(
210
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType',
211
            $this->referenceType,
212
            $msg
213
        )) {
214
            return false;
215
        }
216
        if (!$this->isValidArrayOK(
217
            $this->rowType,
218
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType',
219
            $msg
220
        )) {
221
            return false;
222
        }
223
224
        $count = (isset($this->collectionType) ? 1 : 0)
225
                 + (isset($this->referenceType) ? 1 : 0)
226
                 + (0 < count($this->rowType) ? 1 : 0);
227
        if (1 < $count) {
228
            $msg = "At most one of collection type, reference type and row type can be set/nonempty";
229
            return false;
230
        }
231
232
        return true;
233
    }
234
}
235

src/MetadataV3/edm/TPropertyType.php 1 location

@@ 17-234 (lines=218) @@
14
 *
15
 * XSD Type: TProperty
16
 */
17
class TPropertyType extends IsOK
18
{
19
    use IsOKToolboxTrait, TFacetAttributesTrait, TSimpleIdentifierTrait, TWrappedFunctionReturnTypeTrait;
20
    /**
21
     * @property string $name
22
     */
23
    private $name = null;
24
25
    /**
26
     * @property string $type
27
     */
28
    private $type = null;
29
30
    /**
31
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType
32
     */
33
    private $collectionType = null;
34
35
    /**
36
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType
37
     */
38
    private $referenceType = null;
39
40
    /**
41
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType
42
     */
43
    private $rowType = [];
44
45
    /**
46
     * Gets as name
47
     *
48
     * @return string
49
     */
50
    public function getName()
51
    {
52
        return $this->name;
53
    }
54
55
    /**
56
     * Sets a new name
57
     *
58
     * @param string $name
59
     * @return self
60
     */
61
    public function setName($name)
62
    {
63
        $this->name = $name;
64
        return $this;
65
    }
66
67
    /**
68
     * Gets as type
69
     *
70
     * @return string
71
     */
72
    public function getType()
73
    {
74
        return $this->type;
75
    }
76
77
    /**
78
     * Sets a new type
79
     *
80
     * @param string $type
81
     * @return self
82
     */
83
    public function setType($type)
84
    {
85
        $this->type = $type;
86
        return $this;
87
    }
88
89
    /**
90
     * Gets as collectionType
91
     *
92
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType
93
     */
94
    public function getCollectionType()
95
    {
96
        return $this->collectionType;
97
    }
98
99
    /**
100
     * Sets a new collectionType
101
     *
102
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType
103
     * @return self
104
     */
105
    public function setCollectionType(TCollectionTypeType $collectionType)
106
    {
107
        $this->collectionType = $collectionType;
108
        return $this;
109
    }
110
111
    /**
112
     * Gets as referenceType
113
     *
114
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType
115
     */
116
    public function getReferenceType()
117
    {
118
        return $this->referenceType;
119
    }
120
121
    /**
122
     * Sets a new referenceType
123
     *
124
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType
125
     * @return self
126
     */
127
    public function setReferenceType(TReferenceTypeType $referenceType)
128
    {
129
        $this->referenceType = $referenceType;
130
        return $this;
131
    }
132
133
    /**
134
     * Adds as property
135
     *
136
     * @return self
137
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType $property
138
     */
139
    public function addToRowType(TPropertyType $property)
140
    {
141
        $this->rowType[] = $property;
142
        return $this;
143
    }
144
145
    /**
146
     * isset rowType
147
     *
148
     * @param scalar $index
149
     * @return boolean
150
     */
151
    public function issetRowType($index)
152
    {
153
        return isset($this->rowType[$index]);
154
    }
155
156
    /**
157
     * unset rowType
158
     *
159
     * @param scalar $index
160
     * @return void
161
     */
162
    public function unsetRowType($index)
163
    {
164
        unset($this->rowType[$index]);
165
    }
166
167
    /**
168
     * Gets as rowType
169
     *
170
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[]
171
     */
172
    public function getRowType()
173
    {
174
        return $this->rowType;
175
    }
176
177
    /**
178
     * Sets a new rowType
179
     *
180
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType
181
     * @return self
182
     */
183
    public function setRowType(array $rowType)
184
    {
185
        $this->rowType = $rowType;
186
        return $this;
187
    }
188
189
    public function isOK(&$msg = null)
190
    {
191
        if (!$this->isTSimpleIdentifierValid($this->name)) {
192
            $msg = "Name must be a valid TSimpleIdentifier";
193
            return false;
194
        }
195
        if (null != $this->type && !$this->isTWrappedFunctionTypeValid($this->type)) {
196
            $msg = "Type must be a valid TWrappedFunctionType";
197
            return false;
198
        }
199
        if (!$this->isTFacetAttributesTraitValid($msg)) {
200
            return false;
201
        }
202
        if (!$this->isObjectNullOrType(
203
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType',
204
            $this->collectionType,
205
            $msg
206
        )) {
207
            return false;
208
        }
209
        if (!$this->isObjectNullOrType(
210
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType',
211
            $this->referenceType,
212
            $msg
213
        )) {
214
            return false;
215
        }
216
        if (!$this->isValidArrayOK(
217
            $this->rowType,
218
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType',
219
            $msg
220
        )) {
221
            return false;
222
        }
223
224
        $count = (isset($this->collectionType) ? 1 : 0)
225
                 + (isset($this->referenceType) ? 1 : 0)
226
                 + (0 < count($this->rowType) ? 1 : 0);
227
        if (1 < $count) {
228
            $msg = "At most one of collection type, reference type and row type can be set/nonempty";
229
            return false;
230
        }
231
232
        return true;
233
    }
234
}
235