Passed
Push — master ( 143625...0aa694 )
by Alex
03:46
created

TUsingType::isOK()   D

Complexity

Conditions 9
Paths 6

Size

Total Lines 27
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

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