Passed
Branch feature/backend (79c18d)
by Stone
06:15
created

Trick::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Entity;
4
5
use Symfony\Component\Validator\Constraints as Assert;
6
use Gedmo\Mapping\Annotation as Gedmo;
7
use Doctrine\ORM\Mapping as ORM;
8
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
9
10
/**
11
 * @ORM\Entity(repositoryClass="App\Repository\TrickRepository")
12
 * @Gedmo\Loggable
13
 * @UniqueEntity(fields="name", message="this trick already exists")
14
 */
15
class Trick extends AppEntity
16
{
17
18
    const NUMBER_OF_DISPLAYED_TRICKS = 10;
19
20
    /**
21
     * @ORM\Id()
22
     * @ORM\GeneratedValue()
23
     * @ORM\Column(type="integer")
24
     */
25
    private $id;
26
27
    /**
28
     * @ORM\Column(type="string", length=255)
29
     * @Gedmo\Versioned
30
     * @Assert\Length(
31
     *     min=5,
32
     *     max=255,
33
     *     minMessage = "Title must be at least {{ limit }} characters",
34
     *     maxMessage = "Title can not exceed {{ limit }} characters"
35
     * )
36
     */
37
    private $name;
38
39
    /**
40
     * @ORM\Column(type="text")
41
     * @Gedmo\Versioned
42
     */
43
    private $text;
44
45
    /**
46
     * @ORM\Column(type="string", length=255, unique=true)
47
     * @Gedmo\Slug(fields={"name"})
48
     */
49
    private $slug;
50
51
    /**
52
     * @ORM\Column(type="datetime")
53
     * @Gedmo\Timestampable(on="create")
54
     */
55
    private $createdAt;
56
57
    /**
58
     * @ORM\Column(type="datetime")
59
     * @Gedmo\Timestampable(on="update")
60
     */
61
    private $editedAt;
62
63
    /**
64
     * @ORM\ManyToOne(targetEntity="App\Entity\Category", inversedBy="tricks")
65
     * @ORM\JoinColumn(nullable=false)
66
     */
67
    private $category;
68
69
    public function getId(): ?int
70
    {
71
        return $this->id;
72
    }
73
74
    public function getName(): ?string
75
    {
76
        return $this->name;
77
    }
78
79
    public function setName(string $name): self
80
    {
81
        $this->name = $name;
82
83
        return $this;
84
    }
85
86
    public function getText(): ?string
87
    {
88
        return $this->text;
89
    }
90
91
    public function setText(string $text): self
92
    {
93
        $this->text = $text;
94
95
        return $this;
96
    }
97
98
    public function getSlug(): ?string
99
    {
100
        return $this->slug;
101
    }
102
103
    public function setSlug(string $slug): self
104
    {
105
        $this->slug = $slug;
106
107
        return $this;
108
    }
109
110
    public function getCreatedAt(): ?\DateTimeInterface
111
    {
112
        return $this->createdAt;
113
    }
114
115
    public function setCreatedAt(\DateTimeInterface $createdAt): self
116
    {
117
        $this->createdAt = $createdAt;
118
119
        return $this;
120
    }
121
122
    public function getEditedAt(): ?\DateTimeInterface
123
    {
124
        return $this->editedAt;
125
    }
126
127
    public function setEditedAt(\DateTimeInterface $editedAt): self
128
    {
129
        $this->editedAt = $editedAt;
130
131
        return $this;
132
    }
133
134
    public function getCategory(): ?Category
135
    {
136
        return $this->category;
137
    }
138
139
    public function setCategory(?Category $category): self
140
    {
141
        $this->category = $category;
142
143
        return $this;
144
    }
145
146
    public function __toString()
147
    {
148
        return $this->name;
149
    }
150
}
151