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

TAssociationType::setEnd()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
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\TUndottedIdentifierTrait;
7
8
/**
9
 * Class representing TAssociationType
10
 *
11
 *
12
 * XSD Type: TAssociation
13
 */
14
class TAssociationType extends IsOK
15
{
16
    use TUndottedIdentifierTrait;
17
    /**
18
     * @property string $name
19
     */
20
    private $name = 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\TAssociationEndType[] $end
29
     */
30
    private $end = [];
31
32
    /**
33
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TConstraintType $referentialConstraint
34
     */
35
    private $referentialConstraint = null;
36
37
    /**
38
     * Gets as name
39
     *
40
     * @return string
41
     */
42
    public function getName()
43
    {
44
        return $this->name;
45
    }
46
47
    /**
48
     * Sets a new name
49
     *
50
     * @param string $name
51
     * @return self
52
     */
53
    public function setName($name)
54
    {
55
        $this->name = $name;
56
        return $this;
57
    }
58
59
    /**
60
     * Gets as documentation
61
     *
62
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType
63
     */
64
    public function getDocumentation()
65
    {
66
        return $this->documentation;
67
    }
68
69
    /**
70
     * Sets a new documentation
71
     *
72
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
73
     * @return self
74
     */
75
    public function setDocumentation(TDocumentationType $documentation)
76
    {
77
        $this->documentation = $documentation;
78
        return $this;
79
    }
80
81
    /**
82
     * Adds as end
83
     *
84
     * @return self
85
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TAssociationEndType $end
86
     */
87
    public function addToEnd(TAssociationEndType $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 \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TAssociationEndType[]
119
     */
120
    public function getEnd()
121
    {
122
        return $this->end;
123
    }
124
125
    /**
126
     * Sets a new end
127
     *
128
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TAssociationEndType[] $end
129
     * @return self
130
     */
131
    public function setEnd(array $end)
132
    {
133
        $this->end = $end;
134
        return $this;
135
    }
136
137
    /**
138
     * Gets as referentialConstraint
139
     *
140
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TConstraintType
141
     */
142
    public function getReferentialConstraint()
143
    {
144
        return $this->referentialConstraint;
145
    }
146
147
    /**
148
     * Sets a new referentialConstraint
149
     *
150
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TConstraintType $referentialConstraint
151
     * @return self
152
     */
153
    public function setReferentialConstraint(TConstraintType $referentialConstraint)
154
    {
155
        $this->referentialConstraint = $referentialConstraint;
156
        return $this;
157
    }
158
159
    public function isOK(&$msg = null)
160
    {
161
        if (!$this->isStringNotNullOrEmpty($this->name)) {
162
            $msg = "Name cannot be null or empty";
163
            return false;
164
        }
165
        if (!$this->isTUndottedIdentifierValid($this->name)) {
166
            $msg = "Name must be a valid TUndottedIdentifier";
167
            return false;
168
        }
169
        if (!$this->isObjectNullOrOK($this->referentialConstraint, $msg)) {
170
            return false;
171
        }
172
        if (!$this->isValidArrayOK(
173
            $this->documentation,
0 ignored issues
show
Documentation introduced by
$this->documentation is of type object<AlgoWeb\ODataMeta...sdl\TDocumentationType>, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
174
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType',
175
            $msg
176
        )) {
177
            return false;
178
        }
179
        if (!$this->isValidArrayOK(
180
            $this->end,
181
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TAssociationEndType',
182
            $msg,
183
            2,
184
            2
185
        )) {
186
            return false;
187
        }
188
189
        return true;
190
    }
191
}
192