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\GSchemaBodyElementsTrait; |
8
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TNamespaceNameTrait; |
9
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSimpleIdentifierTrait; |
10
|
|
|
use AlgoWeb\ODataMetadata\StringTraits\XSDTopLevelTrait; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class representing TSchemaType |
14
|
|
|
* |
15
|
|
|
* |
16
|
|
|
* XSD Type: TSchema |
17
|
|
|
*/ |
18
|
|
|
class TSchemaType extends IsOK |
19
|
|
|
{ |
20
|
|
|
use IsOKToolboxTrait, GSchemaBodyElementsTrait, TSimpleIdentifierTrait, XSDTopLevelTrait, TNamespaceNameTrait; |
21
|
|
|
/** |
22
|
|
|
* @property string $namespace |
23
|
|
|
*/ |
24
|
|
|
private $namespace = null; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @property string $namespaceUri |
28
|
|
|
*/ |
29
|
|
|
private $namespaceUri = null; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @property string $alias |
33
|
|
|
*/ |
34
|
|
|
private $alias = null; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Gets as namespace |
38
|
|
|
* |
39
|
|
|
* @return string |
40
|
|
|
*/ |
41
|
|
|
public function getNamespace() |
42
|
|
|
{ |
43
|
|
|
return $this->namespace; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Sets a new namespace |
48
|
|
|
* |
49
|
|
|
* @param string $namespace |
50
|
|
|
* @return self |
51
|
|
|
*/ |
52
|
|
|
public function setNamespace($namespace) |
53
|
|
|
{ |
54
|
|
|
$this->namespace = $namespace; |
55
|
|
|
return $this; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Gets as namespaceUri |
60
|
|
|
* |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
public function getNamespaceUri() |
64
|
|
|
{ |
65
|
|
|
return $this->namespaceUri; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Sets a new namespaceUri |
70
|
|
|
* |
71
|
|
|
* @param string $namespaceUri |
72
|
|
|
* @return self |
73
|
|
|
*/ |
74
|
|
|
public function setNamespaceUri($namespaceUri) |
75
|
|
|
{ |
76
|
|
|
$this->namespaceUri = $namespaceUri; |
77
|
|
|
return $this; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Gets as alias |
82
|
|
|
* |
83
|
|
|
* @return string |
84
|
|
|
*/ |
85
|
|
|
public function getAlias() |
86
|
|
|
{ |
87
|
|
|
return $this->alias; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Sets a new alias |
92
|
|
|
* |
93
|
|
|
* @param string $alias |
94
|
|
|
* @return self |
95
|
|
|
*/ |
96
|
|
|
public function setAlias($alias) |
97
|
|
|
{ |
98
|
|
|
$this->alias = $alias; |
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function isOK(&$msg = null) |
103
|
|
|
{ |
104
|
|
|
if (!$this->isTNamespaceNameValid($this->namespace)) { |
105
|
|
|
$msg = "Namespace must be a valid TNamespaceName"; |
106
|
|
|
return false; |
107
|
|
|
} |
108
|
|
View Code Duplication |
if (null != $this->alias && !$this->isTSimpleIdentifierValid($this->alias)) { |
|
|
|
|
109
|
|
|
$msg = "Alias must be a valid TSimpleIdentifier"; |
110
|
|
|
return false; |
111
|
|
|
} |
112
|
|
|
if (null != $this->namespaceUri && !$this->isURLValid($this->namespaceUri)) { |
113
|
|
|
$msg = "Namespace url must be a valid url"; |
114
|
|
|
return false; |
115
|
|
|
} |
116
|
|
|
if ($this->isGSchemaBodyElementsValid($msg)) { |
117
|
|
|
return false; |
118
|
|
|
} |
119
|
|
|
return true; |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|
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.