Completed
Push — master ( 1b7170...9fa28d )
by Alex
05:38
created

TDesignerType::isOK()   C

Complexity

Conditions 7
Paths 5

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 6.9811
c 0
b 0
f 0
cc 7
eloc 13
nc 5
nop 1
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\MetadataV3\edmx;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
7
/**
8
 * Class representing TDesignerType
9
 *
10
 * XSD Type: TDesigner
11
 */
12
class TDesignerType extends IsOK
13
{
14
15
    /**
16
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edmx\TConnectionType $connection
17
     */
18
    private $connection = null;
19
20
    /**
21
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edmx\TOptionsType $options
22
     */
23
    private $options = null;
24
25
    /**
26
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edmx\TDiagramType[] $diagrams
27
     */
28
    private $diagrams = [];
29
30
    /**
31
     * Gets as connection
32
     *
33
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edmx\TConnectionType
34
     */
35
    public function getConnection()
36
    {
37
        return $this->connection;
38
    }
39
40
    /**
41
     * Sets a new connection
42
     *
43
     * @param  \AlgoWeb\ODataMetadata\MetadataV3\edmx\TConnectionType $connection
44
     * @return self
45
     */
46
    public function setConnection(TConnectionType $connection)
47
    {
48
        $msg = null;
49
        if (!$connection->isOK($msg)) {
50
            throw new \InvalidArgumentException($msg);
51
        }
52
        $this->connection = $connection;
53
        return $this;
54
    }
55
56
    /**
57
     * Gets as options
58
     *
59
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edmx\TOptionsType
60
     */
61
    public function getOptions()
62
    {
63
        return $this->options;
64
    }
65
66
    /**
67
     * Sets a new options
68
     *
69
     * @param  \AlgoWeb\ODataMetadata\MetadataV3\edmx\TOptionsType $options
70
     * @return self
71
     */
72
    public function setOptions(TOptionsType $options)
73
    {
74
        $msg = null;
75
        if (!$options->isOK($msg)) {
76
            throw new \InvalidArgumentException($msg);
77
        }
78
        $this->options = $options;
79
        return $this;
80
    }
81
82
    /**
83
     * Adds as diagram
84
     *
85
     * @return self
86
     * @param  \AlgoWeb\ODataMetadata\MetadataV3\edmx\TDiagramType $diagram
87
     */
88
    public function addToDiagrams(TDiagramType $diagram)
89
    {
90
        $msg = null;
91
        if (!$diagram->isOK($msg)) {
92
            throw new \InvalidArgumentException($msg);
93
        }
94
        $this->diagrams[] = $diagram;
95
        return $this;
96
    }
97
98
    /**
99
     * isset diagrams
100
     *
101
     * @param  scalar $index
102
     * @return boolean
103
     */
104
    public function issetDiagrams($index)
105
    {
106
        return isset($this->diagrams[$index]);
107
    }
108
109
    /**
110
     * unset diagrams
111
     *
112
     * @param  scalar $index
113
     * @return void
114
     */
115
    public function unsetDiagrams($index)
116
    {
117
        unset($this->diagrams[$index]);
118
    }
119
120
    /**
121
     * Gets as diagrams
122
     *
123
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edmx\TDiagramType[]
124
     */
125
    public function getDiagrams()
126
    {
127
        return $this->diagrams;
128
    }
129
130
    /**
131
     * Sets a new diagrams
132
     *
133
     * @param  \AlgoWeb\ODataMetadata\MetadataV3\edmx\TDiagramType[] $diagrams
134
     * @return self
135
     */
136
    public function setDiagrams(array $diagrams)
137
    {
138
        if (!$this->isValidArrayOK(
139
            $diagrams,
140
            '\AlgoWeb\ODataMetadata\MetadataV3\edmx\TDiagramType'
141
        )
142
        ) {
143
            $msg = "Diagrams array not a valid array";
144
            throw new \InvalidArgumentException($msg);
145
        }
146
        $this->diagrams = $diagrams;
147
        return $this;
148
    }
149
150
    public function isOK(&$msg = null)
151
    {
152
        if (null != $this->connection && !$this->connection->isOK($msg)) {
153
            return false;
154
        }
155
        if (null != $this->options && !$this->options->isOK($msg)) {
156
            return false;
157
        }
158
159
        if (!$this->isValidArray(
160
            $this->diagrams,
161
            '\AlgoWeb\ODataMetadata\MetadataV3\edmx\TDiagramType'
162
        )
163
        ) {
164
            $msg = "Diagrams array not a valid array";
165
            return false;
166
        }
167
        if (!$this->isChildArrayOK($this->diagrams, $msg)) {
168
            return false;
169
        }
170
        return true;
171
    }
172
}
173