1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\IsOK; |
6
|
|
|
use AlgoWeb\ODataMetadata\IsOKTraits\IsOKToolboxTrait; |
7
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer\AssociationSetAnonymousType\EndAnonymousType; |
8
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\Groups\GEmptyElementExtensibilityTrait; |
9
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TQualifiedNameTrait; |
10
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSimpleIdentifierTrait; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class representing AssociationSetAnonymousType |
14
|
|
|
*/ |
15
|
|
|
class AssociationSetAnonymousType extends IsOK |
16
|
|
|
{ |
17
|
|
|
use IsOKToolboxTrait, GEmptyElementExtensibilityTrait, TSimpleIdentifierTrait, TQualifiedNameTrait; |
18
|
|
|
/** |
19
|
|
|
* @property string $name |
20
|
|
|
*/ |
21
|
|
|
private $name = null; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @property string $association |
25
|
|
|
*/ |
26
|
|
|
private $association = null; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @property |
30
|
|
|
* \AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer\AssociationSetAnonymousType\EndAnonymousType[] |
31
|
|
|
* $end |
32
|
|
|
*/ |
33
|
|
|
private $end = []; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Gets as name |
37
|
|
|
* |
38
|
|
|
* @return string |
39
|
|
|
*/ |
40
|
|
|
public function getName() |
41
|
|
|
{ |
42
|
|
|
return $this->name; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Sets a new name |
47
|
|
|
* |
48
|
|
|
* @param string $name |
49
|
|
|
* @return self |
50
|
|
|
*/ |
51
|
|
|
public function setName($name) |
52
|
|
|
{ |
53
|
|
|
$this->name = $name; |
54
|
|
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Gets as association |
59
|
|
|
* |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
|
|
public function getAssociation() |
63
|
|
|
{ |
64
|
|
|
return $this->association; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Sets a new association |
69
|
|
|
* |
70
|
|
|
* @param string $association |
71
|
|
|
* @return self |
72
|
|
|
*/ |
73
|
|
|
public function setAssociation($association) |
74
|
|
|
{ |
75
|
|
|
$this->association = $association; |
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Adds as end |
81
|
|
|
* |
82
|
|
|
* @return self |
83
|
|
|
* @param |
84
|
|
|
* \AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer\AssociationSetAnonymousType\EndAnonymousType |
85
|
|
|
* $end |
86
|
|
|
*/ |
87
|
|
|
public function addToEnd(EndAnonymousType $end) |
88
|
|
|
{ |
89
|
|
|
$this->end[] = $end; |
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* isset end |
95
|
|
|
* |
96
|
|
|
* @param scalar $index |
97
|
|
|
* @return boolean |
98
|
|
|
*/ |
99
|
|
|
public function issetEnd($index) |
100
|
|
|
{ |
101
|
|
|
return isset($this->end[$index]); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* unset end |
106
|
|
|
* |
107
|
|
|
* @param scalar $index |
108
|
|
|
* @return void |
109
|
|
|
*/ |
110
|
|
|
public function unsetEnd($index) |
111
|
|
|
{ |
112
|
|
|
unset($this->end[$index]); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Gets as end |
117
|
|
|
* |
118
|
|
|
* @return |
119
|
|
|
* \AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer\AssociationSetAnonymousType\EndAnonymousType[] |
120
|
|
|
*/ |
121
|
|
|
public function getEnd() |
122
|
|
|
{ |
123
|
|
|
return $this->end; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Sets a new end |
128
|
|
|
* |
129
|
|
|
* @param |
130
|
|
|
* \AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer\AssociationSetAnonymousType\EndAnonymousType[] |
131
|
|
|
* $end |
132
|
|
|
* @return self |
133
|
|
|
*/ |
134
|
|
|
public function setEnd(array $end) |
135
|
|
|
{ |
136
|
|
|
$this->end = $end; |
137
|
|
|
return $this; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
View Code Duplication |
public function isOK(&$msg = null) |
|
|
|
|
141
|
|
|
{ |
142
|
|
|
if (!$this->isTSimpleIdentifierValid($this->name)) { |
143
|
|
|
$msg = "Name must be a valid TSimpleIdentifier"; |
144
|
|
|
return false; |
145
|
|
|
} |
146
|
|
|
if (!$this->isTQualifiedNameValid($this->association)) { |
147
|
|
|
$msg = "Association must be a valid TQualifiedName"; |
148
|
|
|
return false; |
149
|
|
|
} |
150
|
|
|
if (!$this->isValidArrayOK( |
151
|
|
|
$this->end, |
152
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer\AssociationSetAnonymousType\EndAnonymousType', |
153
|
|
|
$msg, |
154
|
|
|
0, |
155
|
|
|
2 |
156
|
|
|
)) { |
157
|
|
|
return false; |
158
|
|
|
} |
159
|
|
|
if (!$this->isExtensibilityElementOK($msg)) { |
160
|
|
|
return false; |
161
|
|
|
} |
162
|
|
|
return true; |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
|
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.