Completed
Push — master ( 3d485f...407dff )
by Paweł
66:49
created

Container::getUpdatedAt()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 3
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 6
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Template Engine Bundle.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\TemplatesSystemBundle\Model;
16
17
use Doctrine\Common\Collections\ArrayCollection;
18
use SWP\Component\Common\Model\TimestampableInterface;
19
use SWP\Component\Common\Model\TimestampableTrait;
20
use SWP\Component\TemplatesSystem\Gimme\Model\ContainerDataInterface;
21
use SWP\Component\TemplatesSystem\Gimme\Model\ContainerInterface;
22
23
/**
24
 * Container.
25
 */
26
class Container implements ContainerInterface, TimestampableInterface
27
{
28
    use TimestampableTrait;
29
30
    const TYPE_SIMPLE = 1;
31
32
    /**
33
     * @var int
34
     */
35
    protected $id;
36
37
    /**
38
     * @var int
39
     */
40
    protected $type;
41
42
    /**
43
     * @var string
44
     */
45
    protected $name;
46
47
    /**
48
     * @var string
49
     */
50
    protected $styles;
51
52
    /**
53
     * @var string
54
     */
55
    protected $cssClass;
56
57
    /**
58
     * @var bool
59
     */
60
    protected $visible;
61
62
    /**
63
     * @var ArrayCollection
64
     */
65
    protected $data;
66
67
    /**
68
     * @var ArrayCollection
69
     */
70
    protected $widgets;
71
72
    /**
73
     * Container constructor.
74
     */
75
    public function __construct()
76
    {
77
        $this->createdAt = new \DateTime();
78
        $this->data = new ArrayCollection();
79
        $this->widgets = new ArrayCollection();
80
        $this->setType(self::TYPE_SIMPLE);
81
        $this->setVisible(true);
82
    }
83
84
    /**
85
     * Get id.
86
     *
87
     * @return int
88 7
     */
89
    public function getId()
90 7
    {
91 7
        return $this->id;
92 7
    }
93 7
94 7
    /**
95 7
     * Set id.
96
     *
97
     * @param int $id
98
     *
99
     * @return self
100
     */
101
    public function setId($id)
102 7
    {
103
        $this->id = $id;
104 7
105
        return $this;
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     */
111
    public function setName($name)
112
    {
113
        $this->name = $name;
114
115
        return $this;
116
    }
117
118
    /**
119
     * {@inheritdoc}
120
     */
121
    public function getName()
122
    {
123
        return $this->name;
124
    }
125
126
    /**
127
     * {@inheritdoc}
128 7
     */
129
    public function getStyles()
130 7
    {
131
        return $this->styles;
132 7
    }
133
134
    /**
135
     * {@inheritdoc}
136
     */
137
    public function setStyles(string $styles)
138
    {
139
        $this->styles = $styles;
140 3
141
        return $this;
142 3
    }
143
144
    /**
145
     * {@inheritdoc}
146
     */
147
    public function getCssClass()
148
    {
149
        return $this->cssClass;
150 3
    }
151
152 3
    /**
153
     * {@inheritdoc}
154
     */
155
    public function setCssClass(string $cssClass)
156
    {
157
        $this->cssClass = $cssClass;
158
159
        return $this;
160
    }
161
162 7
    /**
163
     * {@inheritdoc}
164 7
     */
165
    public function getVisible()
166 7
    {
167
        return $this->visible;
168
    }
169
170
    /**
171
     * {@inheritdoc}
172
     */
173
    public function setVisible(bool $visible)
174 3
    {
175
        $this->visible = $visible;
176 3
177
        return $this;
178
    }
179
180
    /**
181
     * {@inheritdoc}
182
     */
183
    public function getData()
184
    {
185
        return $this->data;
186 7
    }
187
188 7
    /**
189
     * {@inheritdoc}
190 7
     */
191
    public function setData(ArrayCollection $data)
192
    {
193
        $this->data = $data;
194
195
        return $this;
196
    }
197
198 3
    /**
199
     * {@inheritdoc}
200 3
     */
201
    public function addData(ContainerDataInterface $containerData)
202
    {
203
        $this->data->add($containerData);
204
205
        return $this;
206
    }
207
208
    /**
209
     * {@inheritdoc}
210 7
     */
211
    public function getType()
212 7
    {
213
        return $this->type;
214 7
    }
215
216
    /**
217
     * {@inheritdoc}
218
     */
219
    public function setType($type)
220
    {
221
        $this->type = $type;
222 3
223
        return $this;
224 3
    }
225
226
    /**
227
     * {@inheritdoc}
228
     */
229
    public function getWidgets()
230
    {
231
        return $this->widgets;
232
    }
233
234 7
    /**
235
     * {@inheritdoc}
236 7
     */
237
    public function setWidgets(ArrayCollection $widgets)
238 7
    {
239
        $this->widgets = $widgets;
240
241
        return $this;
242
    }
243
244
    /**
245
     * {@inheritdoc}
246 3
     */
247
    public function addWidget($widget)
248 3
    {
249
        $this->widgets->add($widget);
250
251
        return $this;
252
    }
253
254
    /**
255
     * {@inheritdoc}
256
     */
257
    public function removeWidget($widget)
258 7
    {
259
        $this->widgets->removeElement($widget);
260 7
261
        return $this;
262 7
    }
263
}
264