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

TReferentialConstraintRoleElementType::isOK()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 11

Duplication

Lines 17
Ratio 100 %

Importance

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