1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV3\edm\Groups; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\CodeGeneration\AccessTypeTraits; |
6
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TQualifiedNameTrait; |
7
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSimpleIdentifierTrait; |
8
|
|
|
|
9
|
|
|
trait TEntitySetAttributesTrait |
10
|
|
|
{ |
11
|
|
|
use TSimpleIdentifierTrait, TQualifiedNameTrait, AccessTypeTraits; |
12
|
|
|
/** |
13
|
|
|
* @property string $name |
14
|
|
|
*/ |
15
|
|
|
private $name = null; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @property string $entityType |
19
|
|
|
*/ |
20
|
|
|
private $entityType = null; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @property string $getterAccess |
24
|
|
|
*/ |
25
|
|
|
private $getterAccess = null; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Gets as name |
29
|
|
|
* |
30
|
|
|
* @return string |
31
|
|
|
*/ |
32
|
|
|
public function getName() |
33
|
|
|
{ |
34
|
|
|
return $this->name; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Sets a new name |
39
|
|
|
* |
40
|
|
|
* @param string $name |
41
|
|
|
* @return self |
42
|
|
|
*/ |
43
|
|
|
public function setName($name) |
44
|
|
|
{ |
45
|
|
|
$this->name = $name; |
46
|
|
|
return $this; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Gets as entityType |
51
|
|
|
* |
52
|
|
|
* @return string |
53
|
|
|
*/ |
54
|
|
|
public function getEntityType() |
55
|
|
|
{ |
56
|
|
|
return $this->entityType; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Sets a new entityType |
61
|
|
|
* |
62
|
|
|
* @param string $entityType |
63
|
|
|
* @return self |
64
|
|
|
*/ |
65
|
|
|
public function setEntityType($entityType) |
66
|
|
|
{ |
67
|
|
|
$this->entityType = $entityType; |
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Gets as getterAccess |
73
|
|
|
* |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public function getGetterAccess() |
77
|
|
|
{ |
78
|
|
|
return $this->getterAccess; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Sets a new getterAccess |
83
|
|
|
* |
84
|
|
|
* @param string $getterAccess |
85
|
|
|
* @return self |
86
|
|
|
*/ |
87
|
|
|
public function setGetterAccess($getterAccess) |
88
|
|
|
{ |
89
|
|
|
$this->getterAccess = $getterAccess; |
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
public function isTEntitySetAttributesOK(&$msg = null) |
95
|
|
|
{ |
96
|
|
View Code Duplication |
if (null != $this->name && !$this->isTSimpleIdentifierValid($this->name)) { |
|
|
|
|
97
|
|
|
$msg = "Name must be a valid TSimpleIdentifier"; |
98
|
|
|
return false; |
99
|
|
|
} |
100
|
|
|
if (null != $this->entityType && !$this->isTQualifiedNameValid($this->entityType)) { |
101
|
|
|
$msg = "Entity type must be a valid TQualifiedName"; |
102
|
|
|
return false; |
103
|
|
|
} |
104
|
|
View Code Duplication |
if (null != $this->getterAccess && !$this->isTAccessOk($this->getterAccess)) { |
|
|
|
|
105
|
|
|
$msg = "Getter access must be a valid TAccess"; |
106
|
|
|
return false; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
return true; |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|
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.