Test Failed
Push — master ( 0f618b...fb6850 )
by Alex
09:40
created

TAssociationEndType::setDocumentation()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 6
nc 2
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\TMultiplicityTrait;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TQualifiedNameTrait;
8
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TSimpleIdentifierTrait;
9
10
/**
11
 * Class representing TAssociationEndType
12
 *
13
 *
14
 * XSD Type: TAssociationEnd
15
 */
16
class TAssociationEndType extends IsOK
17
{
18
    use TSimpleIdentifierTrait, TQualifiedNameTrait, TMultiplicityTrait, TOperations;
19
    /**
20
     * @property string $type
21
     */
22
    private $type = null;
23
24
    /**
25
     * @property string $role
26
     */
27
    private $role = null;
28
29
    /**
30
     * @property string $multiplicity
31
     */
32
    private $multiplicity = null;
33
34
    /**
35
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
36
     */
37
    private $documentation = null;
38
39
    /**
40
     * Gets as type
41
     *
42
     * @return string
43
     */
44
    public function getType()
45
    {
46
        return $this->type;
47
    }
48
49
    /**
50
     * Sets a new type
51
     *
52
     * @param string $type
53
     * @return self
54
     */
55
    public function setType($type)
56
    {
57
        if (!$this->isStringNotNullOrEmpty($type)) {
58
            $msg = "Type cannot be null or empty";
59
            throw new \InvalidArgumentException($msg);
60
        }
61
        $this->type = $type;
62
        return $this;
63
    }
64
65
    /**
66
     * Gets as role
67
     *
68
     * @return string
69
     */
70
    public function getRole()
71
    {
72
        return $this->role;
73
    }
74
75
    /**
76
     * Sets a new role
77
     *
78
     * @param string $role
79
     * @return self
80
     */
81
    public function setRole($role)
82
    {
83
        if (null != $role && !$this->isStringNotNullOrEmpty($role)) {
84
            $msg = "Role cannot be empty";
85
            throw new \InvalidArgumentException($msg);
86
        }
87
        if (null != $role && !$this->isTSimpleIdentifierValid($role)) {
88
            $msg = "Role must be a valid TSimpleIdentifier";
89
            throw new \InvalidArgumentException($msg);
90
        }
91
        $this->role = $role;
92
        return $this;
93
    }
94
95
    /**
96
     * Gets as multiplicity
97
     *
98
     * @return string
99
     */
100
    public function getMultiplicity()
101
    {
102
        return $this->multiplicity;
103
    }
104
105
    /**
106
     * Sets a new multiplicity
107
     *
108
     * @param string $multiplicity
109
     * @return self
110
     */
111 View Code Duplication
    public function setMultiplicity($multiplicity)
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...
112
    {
113
        $msg = null;
0 ignored issues
show
Unused Code introduced by
$msg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
114
        if (!$this->isStringNotNullOrEmpty($multiplicity)) {
115
            $msg = "Multiplicity cannot be null or empty";
116
            throw new \InvalidArgumentException($msg);
117
        }
118
        if (!$this->isTMultiplicityValid($multiplicity)) {
119
            $msg = "Multiplicity must be a valid TMultiplicity";
120
            throw new \InvalidArgumentException($msg);
121
        }
122
        $this->multiplicity = $multiplicity;
123
        return $this;
124
    }
125
126
    /**
127
     * Gets as documentation
128
     *
129
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType
130
     */
131
    public function getDocumentation()
132
    {
133
        return $this->documentation;
134
    }
135
136
    /**
137
     * Sets a new documentation
138
     *
139
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
140
     * @return self
141
     */
142 View Code Duplication
    public function setDocumentation(TDocumentationType $documentation)
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...
143
    {
144
        $msg = null;
145
        if (!$documentation->isOK($msg)) {
146
            throw new \InvalidArgumentException($msg);
147
        }
148
        $this->documentation = $documentation;
149
        return $this;
150
    }
151
    
152
    public function isOK(&$msg = null)
153
    {
154
        if (!$this->isStringNotNullOrEmpty($this->type)) {
155
            $msg = "Type cannot be null or empty";
156
            return false;
157
        }
158
        if (!$this->isStringNotNullOrEmpty($this->multiplicity)) {
159
            $msg = "Multiplicity cannot be null or empty";
160
            return false;
161
        }
162 View Code Duplication
        if (null != $this->role && !$this->isStringNotNullOrEmpty($this->role)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
163
            $msg = "Role cannot be empty";
164
            return false;
165
        }
166
        if (null != $this->role && !$this->isTSimpleIdentifierValid($this->role)) {
167
            $msg = "Role must be a valid TSimpleIdentifier";
168
            return false;
169
        }
170
        if (!$this->isTMultiplicityValid($this->multiplicity)) {
171
            $msg = "Multiplicity must be a valid TMultiplicity";
172
            return false;
173
        }
174
        if (!$this->isOperationsGroupOK($msg)) {
175
            return false;
176
        }
177
178
        return true;
179
    }
180
}
181