Completed
Push — master ( b05893...eedd1b )
by Julito
09:17
created

Category::setCreatedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\FaqBundle\Entity;
5
6
use Doctrine\ORM\Mapping as ORM;
7
use Gedmo\Mapping\Annotation as Gedmo;
8
use Gedmo\Timestampable\Traits\TimestampableEntity;
9
use Knp\DoctrineBehaviors\Model as ORMBehaviors;
10
11
/**
12
 * Class Category.
13
 *
14
 * @ORM\Entity(repositoryClass="Chamilo\FaqBundle\Repository\CategoryRepository")
15
 * @ORM\Table(
16
 *     name="faq_category",
17
 *     indexes={@ORM\Index(name="is_active_idx", columns={"is_active"})}
18
 * )
19
 */
20
class Category
21
{
22
    use ORMBehaviors\Translatable\Translatable;
23
    use TimestampableEntity;
24
25
    /**
26
     * @ORM\Column(type="integer")
27
     * @ORM\Id
28
     * @ORM\GeneratedValue(strategy="AUTO")
29
     */
30
    protected $id;
31
32
    /**
33
     * @ORM\OneToMany(targetEntity="Question", mappedBy="category")
34
     */
35
    protected $questions;
36
37
    /**
38
     * @Gedmo\SortablePosition
39
     *
40
     * @ORM\Column(name="`rank`", type="integer")
41
     */
42
    protected $rank;
43
44
    /**
45
     * @ORM\Column(name="is_active", type="boolean")
46
     */
47
    protected $isActive;
48
49
    /**
50
     * @param $method
51
     * @param $arguments
52
     *
53
     * @return mixed
54
     */
55
    public function __call($method, $arguments)
56
    {
57
        return $this->proxyCurrentLocaleTranslation($method, $arguments);
58
    }
59
60
    /**
61
     * Returns a string representation of this object.
62
     *
63
     * @return string
64
     */
65
    public function __toString()
66
    {
67
        return (string) $this->getHeadline();
68
    }
69
70
    /**
71
     * Get id.
72
     *
73
     * @return int
74
     */
75
    public function getId()
76
    {
77
        return $this->id;
78
    }
79
80
    /**
81
     * Get rank.
82
     *
83
     * @return string
84
     */
85
    public function getRank()
86
    {
87
        return $this->rank;
88
    }
89
90
    /**
91
     * Set rank.
92
     *
93
     * @param string $rank
94
     *
95
     * @return Question
96
     */
97
    public function setRank($rank)
98
    {
99
        $this->rank = $rank;
0 ignored issues
show
Documentation Bug introduced by
The property $rank was declared of type integer, but $rank is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
100
101
        return $this;
102
    }
103
104
    /**
105
     * Set is_active.
106
     *
107
     * @param bool $isActive
108
     *
109
     * @return Category
110
     */
111
    public function setIsActive($isActive)
112
    {
113
        $this->isActive = $isActive;
114
115
        return $this;
116
    }
117
118
    /**
119
     * Get isActive.
120
     *
121
     * @return bool
122
     */
123
    public function getIsActive()
124
    {
125
        return $this->isActive;
126
    }
127
128
    /**
129
     * Add question.
130
     *
131
     * @param Question $question
132
     *
133
     * @return Category
134
     */
135
    public function addQuestion(Question $question)
136
    {
137
        $this->questions[] = $question;
138
139
        return $this;
140
    }
141
142
    /**
143
     * Remove question.
144
     *
145
     * @param Question $question
146
     */
147
    public function removeQuestion(Question $question)
148
    {
149
        $this->questions->removeElement($question);
150
    }
151
152
    /**
153
     * Get questions.
154
     *
155
     * @return \Doctrine\Common\Collections\Collection
156
     */
157
    public function getQuestions()
158
    {
159
        return $this->questions;
160
    }
161
162
    /**
163
     * Returns the route name for url generation.
164
     *
165
     * @return string
166
     */
167
    public function getRouteName()
168
    {
169
        return 'faq';
170
    }
171
172
    /**
173
     * Returns the route parameters for url generation.
174
     *
175
     * @return array
176
     */
177
    public function getRouteParameters()
178
    {
179
        return [
180
            'categorySlug' => $this->getSlug(),
181
        ];
182
    }
183
}
184