Passed
Push — master ( d2da49...fac384 )
by Alex
03:51
created

TReferentialConstraintRoleElementType::isOK()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 23
Code Lines 16

Duplication

Lines 23
Ratio 100 %

Importance

Changes 0
Metric Value
dl 23
loc 23
rs 8.5906
c 0
b 0
f 0
cc 5
eloc 16
nc 5
nop 1
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TSimpleIdentifierTrait;
7
8
/**
9
 * Class representing TReferentialConstraintRoleElementType
10
 *
11
 *
12
 * XSD Type: TReferentialConstraintRoleElement
13
 */
14
class TReferentialConstraintRoleElementType extends IsOK
15
{
16
    use TSimpleIdentifierTrait;
17
    /**
18
     * @property string $role
19
     */
20
    private $role = null;
21
22
    /**
23
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
24
     */
25
    private $documentation = null;
26
27
    /**
28
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType[] $propertyRef
29
     */
30
    private $propertyRef = [];
31
32
    /**
33
     * Gets as role
34
     *
35
     * @return string
36
     */
37
    public function getRole()
38
    {
39
        return $this->role;
40
    }
41
42
    /**
43
     * Sets a new role
44
     *
45
     * @param string $role
46
     * @return self
47
     */
48
    public function setRole($role)
49
    {
50
        $this->role = $role;
51
        return $this;
52
    }
53
54
    /**
55
     * Gets as documentation
56
     *
57
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType
58
     */
59
    public function getDocumentation()
60
    {
61
        return $this->documentation;
62
    }
63
64
    /**
65
     * Sets a new documentation
66
     *
67
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
68
     * @return self
69
     */
70
    public function setDocumentation(TDocumentationType $documentation)
71
    {
72
        $this->documentation = $documentation;
73
        return $this;
74
    }
75
76
    /**
77
     * Adds as propertyRef
78
     *
79
     * @return self
80
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType $propertyRef
81
     */
82
    public function addToPropertyRef(TPropertyRefType $propertyRef)
83
    {
84
        $this->propertyRef[] = $propertyRef;
85
        return $this;
86
    }
87
88
    /**
89
     * isset propertyRef
90
     *
91
     * @param scalar $index
92
     * @return boolean
93
     */
94
    public function issetPropertyRef($index)
95
    {
96
        return isset($this->propertyRef[$index]);
97
    }
98
99
    /**
100
     * unset propertyRef
101
     *
102
     * @param scalar $index
103
     * @return void
104
     */
105
    public function unsetPropertyRef($index)
106
    {
107
        unset($this->propertyRef[$index]);
108
    }
109
110
    /**
111
     * Gets as propertyRef
112
     *
113
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType[]
114
     */
115
    public function getPropertyRef()
116
    {
117
        return $this->propertyRef;
118
    }
119
120
    /**
121
     * Sets a new propertyRef
122
     *
123
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType[] $propertyRef
124
     * @return self
125
     */
126
    public function setPropertyRef(array $propertyRef)
127
    {
128
        $this->propertyRef = $propertyRef;
129
        return $this;
130
    }
131
132 View Code Duplication
    public function isOK(&$msg = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
133
    {
134
        if (!$this->isStringNotNullOrEmpty($this->role)) {
135
            $msg = "Role cannot be empty or null";
136
            return false;
137
        }
138
        if (!$this->isTSimpleIdentifierValid($this->role)) {
139
            $msg = "Role must be valid TSimpleIdentifier";
140
            return false;
141
        }
142
        if (!$this->isObjectNullOrOK($this->documentation, $msg)) {
143
            return false;
144
        }
145
        if (!$this->isValidArrayOK(
146
            $this->propertyRef,
147
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType',
148
            $msg,
149
            1
150
        )) {
151
            return false;
152
        }
153
        return true;
154
    }
155
}
156