Category::setName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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 Symfony\Component\Validator\Constraints as Assert;
9
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
10
use ApiPlatform\Core\Annotation\ApiResource;
11
12
/**
13
 * @ORM\Entity(repositoryClass="App\Repository\CategoryRepository")
14
 * @UniqueEntity(
15
 *     fields={"name"},
16
 *     message="Cette catégorie est déjà enregistrée !"
17
 * )
18
 * @ApiResource
19
 */
20
class Category
21
{
22
    /**
23
     * @ORM\Id()
24
     * @ORM\GeneratedValue()
25
     * @ORM\Column(type="integer")
26
     */
27
    private $id;
28
29
    /**
30
     * @ORM\Column(type="string", length=255)
31
     * @Assert\NotBlank
32
     */
33
    private $name;
34
35
    public function __construct()
36
    {
37
        $this->adverts = new ArrayCollection();
0 ignored issues
show
Bug Best Practice introduced by
The property adverts does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
38
    }
39
40
    public function getId(): ?int
41
    {
42
        return $this->id;
43
    }
44
45
    public function getName(): ?string
46
    {
47
        return $this->name;
48
    }
49
50
    public function setName(string $name): self
51
    {
52
        $this->name = $name;
53
54
        return $this;
55
    }
56
}
57