Passed
Push — master ( eeb046...442ea1 )
by Julito
09:25 queued 26s
created

ResourceComment::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CoreBundle\Entity\Resource;
6
7
use Chamilo\UserBundle\Entity\User;
8
use Doctrine\Common\Collections\ArrayCollection;
9
use Doctrine\ORM\Mapping as ORM;
10
use Gedmo\Mapping\Annotation as Gedmo;
11
use Gedmo\Timestampable\Traits\TimestampableEntity;
12
use Gedmo\Tree\Traits\NestedSetEntity;
13
use JMS\Serializer\Annotation as JMS;
14
use JMS\Serializer\Annotation\Groups;
15
use Symfony\Component\Validator\Constraints as Assert;
16
17
/**
18
 * @Gedmo\Tree(type="nested")
19
 * @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository")
20
 * @ORM\Table(name="resource_comment")
21
 */
22
class ResourceComment
23
{
24
    use TimestampableEntity;
25
    use NestedSetEntity;
26
27
    /**
28
     * @ORM\Id
29
     * @ORM\Column(type="integer")
30
     * @ORM\GeneratedValue(strategy="AUTO")
31
     * @Groups({"list"})
32
     */
33
    protected $id;
34
35
    /**
36
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Resource\ResourceNode", inversedBy="comments")
37
     * @ORM\JoinColumn(name="resource_node_id", referencedColumnName="id", onDelete="SET NULL")
38
     */
39
    protected $resourceNode;
40
41
    /**
42
     * @var User
43
     *
44
     * @Groups({"list"})
45
     * @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User", inversedBy="resourceComments")
46
     * @ORM\JoinColumn(name="author_id", referencedColumnName="id", onDelete="SET NULL")
47
     */
48
    protected $author;
49
50
    /**
51
     * @var string
52
     *
53
     * @Groups({"list"})
54
     * @Assert\NotBlank()
55
     *
56
     * @ORM\Column(name="content", type="string", nullable=false)
57
     */
58
    protected $content;
59
60
    /**
61
     * @Gedmo\TreeParent
62
     *
63
     * @ORM\ManyToOne(
64
     *     targetEntity="ResourceComment",
65
     *     inversedBy="children"
66
     * )
67
     * @ORM\JoinColumns({@ORM\JoinColumn(onDelete="CASCADE")})
68
     */
69
    protected $parent;
70
71
    /**
72
     * @var \DateTime
73
     * @Groups({"list"})
74
     * @Gedmo\Timestampable(on="create")
75
     * @ORM\Column(type="datetime")
76
     * @JMS\Type("DateTime")
77
     */
78
    protected $createdAt;
79
80
    /**
81
     * @var \DateTime
82
     *
83
     * @Groups({"list"})
84
     * @Gedmo\Timestampable(on="update")
85
     * @ORM\Column(type="datetime")
86
     * @JMS\Type("DateTime")
87
     */
88
    protected $updatedAt;
89
90
    /**
91
     * @var ResourceComment[]
92
     *
93
     * @ORM\OneToMany(
94
     *     targetEntity="ResourceComment",
95
     *     mappedBy="parent"
96
     * )
97
     * @ORM\OrderBy({"id" = "ASC"})
98
     */
99
    protected $children;
100
101
    public function __construct()
102
    {
103
        $this->content = '';
104
        $this->children = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new Doctrine\Common\Collections\ArrayCollection() of type Doctrine\Common\Collections\ArrayCollection is incompatible with the declared type Chamilo\CoreBundle\Entit...ource\ResourceComment[] of property $children.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
105
    }
106
107
    public function getId()
108
    {
109
        return $this->id;
110
    }
111
112
    /**
113
     * @return ResourceComment
114
     */
115
    public function setId($id)
116
    {
117
        $this->id = $id;
118
119
        return $this;
120
    }
121
122
    public function getContent(): string
123
    {
124
        return $this->content;
125
    }
126
127
    public function setContent(string $content): self
128
    {
129
        $this->content = $content;
130
131
        return $this;
132
    }
133
134
    public function getResourceNode()
135
    {
136
        return $this->resourceNode;
137
    }
138
139
    /**
140
     * @return ResourceComment
141
     */
142
    public function setResourceNode($resourceNode)
143
    {
144
        $this->resourceNode = $resourceNode;
145
146
        return $this;
147
    }
148
149
    public function getAuthor(): User
150
    {
151
        return $this->author;
152
    }
153
154
    /**
155
     * @return ResourceComment
156
     */
157
    public function setAuthor(User $author)
158
    {
159
        $this->author = $author;
160
161
        return $this;
162
    }
163
164
    public function getParent()
165
    {
166
        return $this->parent;
167
    }
168
169
    /**
170
     * @return ResourceComment
171
     */
172
    public function setParent($parent)
173
    {
174
        $this->parent = $parent;
175
176
        return $this;
177
    }
178
179
    /**
180
     * @return ResourceComment[]
181
     */
182
    public function getChildren(): array
183
    {
184
        return $this->children;
185
    }
186
187
    /**
188
     * @param ResourceComment[] $children
189
     */
190
    public function setChildren(array $children): self
191
    {
192
        $this->children = $children;
193
194
        return $this;
195
    }
196
}
197