Completed
Push — develop ( 117c72...bb7f99 )
by Victor
03:10
created

Category::setCreatedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Gedmo\Mapping\Annotation as Gedmo;
7
use Symfony\Component\Validator\Constraints as Assert;
8
9
/**
10
 * Category
11
 *
12
 * @ORM\Table(name="category")
13
 * @ORM\Entity(repositoryClass="AppBundle\Repository\CategoryRepository")
14
 */
15
class Category
16
{
17
    /**
18
     * @var int
19
     *
20
     * @ORM\Column(name="id", type="integer")
21
     * @ORM\Id
22
     * @ORM\GeneratedValue(strategy="AUTO")
23
     */
24
    private $id;
25
26
    /**
27
     * @var string
28
     *
29
     * @ORM\Column(name="name", type="string", length=50, unique=true)
30
     *
31
     * @Assert\NotBlank()
32
     * @Assert\Length(max = 50)
33
     */
34
    private $name;
35
36
    /**
37
     * @var string
38
     *
39
     * @Gedmo\Slug(fields={"name"}, updatable=true, separator="_")
40
     * @ORM\Column(name="slug", type="string", length=60, unique=true)
41
     *
42
     * @Assert\NotBlank()
43
     * @Assert\Length(max = 60)
44
     */
45
    private $slug;
46
47
    /**
48
     * @ORM\ManyToMany(targetEntity="Article", mappedBy="categories")
49
     */
50
    private $articles;
51
52
    /**
53
     * @var \DateTime
54
     *
55
     * @Gedmo\Timestampable(on="create")
56
     * @ORM\Column(name="created_at", type="datetime")
57
     *
58
     * @Assert\DateTime()
59
     */
60
    private $createdAt;
61
62
    /**
63
     * @var \DateTime
64
     *
65
     * @Gedmo\Timestampable(on="change", field={"name"})
66
     * @ORM\Column(name="updated_at", type="datetime", nullable=true)
67
     *
68
     * @Assert\DateTime()
69
     */
70
    private $updatedAt;
71
72
    /**
73
     * @var \DateTime
74
     *
75
     * @ORM\Column(name="deleted_at", type="datetime", nullable=true)
76
     *
77
     * @Assert\DateTime()
78
     */
79
    private $deletedAt;
80
81
82
    /**
83
     * Get id
84
     *
85
     * @return int
86
     */
87
    public function getId()
88
    {
89
        return $this->id;
90
    }
91
92
    /**
93
     * Set name
94
     *
95
     * @param string $name
96
     *
97
     * @return Category
98
     */
99
    public function setName($name)
100
    {
101
        $this->name = $name;
102
103
        return $this;
104
    }
105
106
    /**
107
     * Get name
108
     *
109
     * @return string
110
     */
111 5
    public function getName()
112
    {
113 5
        return $this->name;
114
    }
115
116
    /**
117
     * Set slug
118
     *
119
     * @param string $slug
120
     *
121
     * @return Category
122
     */
123
    public function setSlug($slug)
124
    {
125
        $this->slug = $slug;
126
127
        return $this;
128
    }
129
130
    /**
131
     * Get slug
132
     *
133
     * @return string
134
     */
135 5
    public function getSlug()
136
    {
137 5
        return $this->slug;
138
    }
139
140
    /**
141
     * Set createdAt
142
     *
143
     * @param \DateTime $createdAt
144
     *
145
     * @return Category
146
     */
147
    public function setCreatedAt($createdAt)
148
    {
149
        $this->createdAt = $createdAt;
150
151
        return $this;
152
    }
153
154
    /**
155
     * Get createdAt
156
     *
157
     * @return \DateTime
158
     */
159
    public function getCreatedAt()
160
    {
161
        return $this->createdAt;
162
    }
163
164
    /**
165
     * Set updatedAt
166
     *
167
     * @param \DateTime $updatedAt
168
     *
169
     * @return Category
170
     */
171
    public function setUpdatedAt($updatedAt)
172
    {
173
        $this->updatedAt = $updatedAt;
174
175
        return $this;
176
    }
177
178
    /**
179
     * Get updatedAt
180
     *
181
     * @return \DateTime
182
     */
183
    public function getUpdatedAt()
184
    {
185
        return $this->updatedAt;
186
    }
187
188
    /**
189
     * Set deletedAt
190
     *
191
     * @param \DateTime $deletedAt
192
     *
193
     * @return Category
194
     */
195
    public function setDeletedAt($deletedAt)
196
    {
197
        $this->deletedAt = $deletedAt;
198
199
        return $this;
200
    }
201
202
    /**
203
     * Get deletedAt
204
     *
205
     * @return \DateTime
206
     */
207
    public function getDeletedAt()
208
    {
209
        return $this->deletedAt;
210
    }
211
    /**
212
     * Constructor
213
     */
214
    public function __construct()
215
    {
216
        $this->articles = new \Doctrine\Common\Collections\ArrayCollection();
217
    }
218
219
    /**
220
     * Add article
221
     *
222
     * @param \AppBundle\Entity\Article $article
223
     *
224
     * @return Category
225
     */
226
    public function addArticle(\AppBundle\Entity\Article $article)
227
    {
228
        $this->articles[] = $article;
229
230
        return $this;
231
    }
232
233
    /**
234
     * Remove article
235
     *
236
     * @param \AppBundle\Entity\Article $article
237
     */
238
    public function removeArticle(\AppBundle\Entity\Article $article)
239
    {
240
        $this->articles->removeElement($article);
241
    }
242
243
    /**
244
     * Get articles
245
     *
246
     * @return \Doctrine\Common\Collections\Collection
247
     */
248
    public function getArticles()
249
    {
250
        return $this->articles;
251
    }
252
}
253