Collection::addRequest()   A
last analyzed

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
/*
4
 * This file is part of the PostmanGeneratorBundle package.
5
 *
6
 * (c) Vincent Chalamon <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PostmanGeneratorBundle\Model;
13
14
class Collection
15
{
16
    /**
17
     * @var string
18
     */
19
    private $id;
20
21
    /**
22
     * @var string
23
     */
24
    private $name;
25
26
    /**
27
     * @var string
28
     */
29
    private $description = '';
30
31
    /**
32
     * @var array
33
     */
34
    private $order = [];
35
36
    /**
37
     * @var Folder[]
38
     */
39
    private $folders = [];
40
41
    /**
42
     * @var int
43
     */
44
    private $timestamp = 0;
45
46
    /**
47
     * @var int
48
     */
49
    private $owner = 0;
50
51
    /**
52
     * @var string
53
     */
54
    private $remoteLink = '';
55
56
    /**
57
     * @var bool
58
     */
59
    private $public = false;
60
61
    /**
62
     * @var Request[]
63
     */
64
    private $requests = [];
65
66
    /**
67
     * @return string
68
     */
69
    public function getId()
70
    {
71
        return $this->id;
72
    }
73
74
    /**
75
     * @param string $id
76
     */
77
    public function setId($id)
78
    {
79
        $this->id = $id;
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public function getName()
86
    {
87
        return $this->name;
88
    }
89
90
    /**
91
     * @param string $name
92
     */
93
    public function setName($name)
94
    {
95
        $this->name = $name;
96
    }
97
98
    /**
99
     * @return string
100
     */
101
    public function getDescription()
102
    {
103
        return $this->description;
104
    }
105
106
    /**
107
     * @param string $description
108
     */
109
    public function setDescription($description)
110
    {
111
        $this->description = $description;
112
    }
113
114
    /**
115
     * @return array
116
     */
117
    public function getOrder()
118
    {
119
        return $this->order;
120
    }
121
122
    /**
123
     * @param array $order
124
     */
125
    public function setOrder(array $order)
126
    {
127
        $this->order = $order;
128
    }
129
130
    /**
131
     * @return int
132
     */
133
    public function getTimestamp()
134
    {
135
        return $this->timestamp;
136
    }
137
138
    /**
139
     * @param int $timestamp
140
     */
141
    public function setTimestamp($timestamp)
142
    {
143
        $this->timestamp = $timestamp;
144
    }
145
146
    /**
147
     * @return int
148
     */
149
    public function getOwner()
150
    {
151
        return $this->owner;
152
    }
153
154
    /**
155
     * @param int $owner
156
     */
157
    public function setOwner($owner)
158
    {
159
        $this->owner = $owner;
160
    }
161
162
    /**
163
     * @return string
164
     */
165
    public function getRemoteLink()
166
    {
167
        return $this->remoteLink;
168
    }
169
170
    /**
171
     * @param string $remoteLink
172
     */
173
    public function setRemoteLink($remoteLink)
174
    {
175
        $this->remoteLink = $remoteLink;
176
    }
177
178
    /**
179
     * @return bool
180
     */
181
    public function isPublic()
182
    {
183
        return $this->public;
184
    }
185
186
    /**
187
     * @param bool $public
188
     */
189
    public function setPublic($public)
190
    {
191
        $this->public = $public;
192
    }
193
194
    /**
195
     * @return Folder[]
196
     */
197
    public function getFolders()
198
    {
199
        return $this->folders;
200
    }
201
202
    /**
203
     * @param Folder $folder
204
     */
205
    public function addFolder(Folder $folder)
206
    {
207
        $folder->setCollection($this);
208
        $this->folders[] = $folder;
209
        $this->mergeRequests($folder->getRequests());
210
    }
211
212
    /**
213
     * @return Request[]
214
     */
215
    public function getRequests()
216
    {
217
        return $this->requests;
218
    }
219
220
    /**
221
     * @param Request $request
222
     */
223
    public function addRequest(Request $request)
224
    {
225
        $request->setCollection($this);
226
        $this->requests[] = $request;
227
    }
228
229
    /**
230
     * @param Request[] $requests
231
     */
232
    public function mergeRequests(array $requests)
233
    {
234
        foreach ($requests as $request) {
235
            $this->addRequest($request);
236
        }
237
    }
238
}
239