Passed
Branch feature/tags (cc2dab)
by Stone
06:13
created

Tag::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\Common\Collections\Collection;
7
use Doctrine\ORM\Mapping as ORM;
8
use Gedmo\Mapping\Annotation as Gedmo;
9
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
10
11
/**
12
 * @ORM\Entity(repositoryClass="App\Repository\TagRepository")
13
 * @UniqueEntity(fields="name", message="this Tag already exists")
14
 */
15
class Tag
16
{
17
    /**
18
     * @ORM\Id()
19
     * @ORM\GeneratedValue()
20
     * @ORM\Column(type="integer")
21
     */
22
    private $id;
23
24
    /**
25
     * @ORM\Column(type="string", length=255, unique=true)
26
     */
27
    private $name;
28
29
    /**
30
     * @ORM\Column(type="string", length=255, unique=true)
31
     * @Gedmo\Slug(fields={"name"})
32
     */
33
    private $slug;
34
35
    /**
36
     * @ORM\ManyToMany(targetEntity="App\Entity\Trick", mappedBy="tags", cascade={"persist"})
37
     */
38
    private $trick;
39
40
    public function __construct()
41
    {
42
        $this->trick = new ArrayCollection();
43
    }
44
45
    public function getId(): ?int
46
    {
47
        return $this->id;
48
    }
49
50
    public function getName(): ?string
51
    {
52
        return $this->name;
53
    }
54
55
    public function setName(string $name): self
56
    {
57
        $this->name = $name;
58
59
        return $this;
60
    }
61
62
    public function getSlug(): ?string
63
    {
64
        return $this->slug;
65
    }
66
67
    public function setSlug(string $slug): self
68
    {
69
        $this->slug = $slug;
70
71
        return $this;
72
    }
73
74
    /**
75
     * @return Collection|Trick[]
76
     */
77
    public function getTrick(): Collection
78
    {
79
        return $this->trick;
80
    }
81
82
    public function addTrick(Trick $trick): self
83
    {
84
        if (!$this->trick->contains($trick)) {
85
            $this->trick[] = $trick;
86
        }
87
88
        return $this;
89
    }
90
91
    public function removeTrick(Trick $trick): self
92
    {
93
        if ($this->trick->contains($trick)) {
94
            $this->trick->removeElement($trick);
95
        }
96
97
        return $this;
98
    }
99
100
    public function __toString()
101
    {
102
        return $this->name;
103
    }
104
}
105