Passed
Push — develop ( d64e19...d2a67e )
by BENARD
04:33
created

Serie::getBadge()   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
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace VideoGamesRecords\CoreBundle\Entity;
4
5
use ApiPlatform\Core\Annotation\ApiFilter;
6
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
7
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
8
use Doctrine\Common\Collections\ArrayCollection;
9
use Doctrine\ORM\Mapping as ORM;
10
use Doctrine\Common\Collections\Collection;
11
use Knp\DoctrineBehaviors\Contract\Entity\SluggableInterface;
12
use Knp\DoctrineBehaviors\Model\Sluggable\SluggableTrait;
13
use Gedmo\Timestampable\Traits\TimestampableEntity;
14
use Symfony\Component\Validator\Constraints as Assert;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Validator\Constraints was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use VideoGamesRecords\CoreBundle\Model\Entity\NbChartTrait;
16
use VideoGamesRecords\CoreBundle\Model\Entity\NbGameTrait;
17
use VideoGamesRecords\CoreBundle\Model\Entity\PictureTrait;
18
use VideoGamesRecords\CoreBundle\ValueObject\SerieStatus;
19
20
/**
21
 * Serie
22
 * @ORM\Table(name="vgr_serie")
23
 * @ORM\Entity(repositoryClass="VideoGamesRecords\CoreBundle\Repository\SerieRepository")
24
 * @ApiFilter(
25
 *     SearchFilter::class,
26
 *     properties={
27
 *          "status": "exact",
28
 *          "libSerie" : "partial",
29
 *      }
30
 * )
31
 * @ApiFilter(
32
 *     OrderFilter::class,
33
 *     properties={
34
 *          "libSerie" : "ASC",
35
 *     },
36
 *     arguments={"orderParameterName"="order"}
37
 * )
38
 */
39
class Serie implements SluggableInterface
40
{
41
    use TimestampableEntity;
42
    use SluggableTrait;
43
    use NbChartTrait;
44
    use NbGameTrait;
45
    use PictureTrait;
46
47
    /**
48
     * @ORM\Column(name="id", type="integer")
49
     * @ORM\Id
50
     * @ORM\GeneratedValue(strategy="IDENTITY")
51
     */
52
    private ?int $id = null;
53
54
    /**
55
     * @var string
56
     * @Assert\Length(max="255")
57
     * @ORM\Column(name="libSerie", type="string", length=255, nullable=false)
58
     */
59
    private string $libSerie;
60
61
    /**
62
     * @ORM\Column(name="status", type="string", nullable=false)
63
     */
64
    private string $status = SerieStatus::STATUS_INACTIVE;
65
66
    /**
67
     * @ORM\OneToMany(targetEntity="VideoGamesRecords\CoreBundle\Entity\Game", mappedBy="serie", cascade={"persist", "remove"}, orphanRemoval=true)
68
     */
69
    private Collection $games;
70
71
    /**
72
     * @ORM\OneToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Badge", inversedBy="serie", cascade={"persist"}))
73
     * @ORM\JoinColumns({
74
     *   @ORM\JoinColumn(name="idBadge", referencedColumnName="id", nullable=true, onDelete="SET NULL")
75
     * })
76
     */
77
    private ?Badge $badge;
78
79
    /**
80
     * Constructor
81
     */
82
    public function __construct()
83
    {
84
        $this->games = new ArrayCollection();
85
    }
86
87
    /**
88
     * @return string
89
     */
90
    public function __toString(): string
91
    {
92
        return sprintf('%s [%s]', $this->getDefaultName(), $this->id);
93
    }
94
95
    /**
96
     * @return string
97
     */
98
    public function getDefaultName(): string
99
    {
100
        return $this->libSerie;
101
    }
102
103
    /**
104
     * @return string
105
     */
106
    public function getName(): string
107
    {
108
        return $this->libSerie;
109
    }
110
111
    /**
112
     * @param string $libSerie
113
     * @return $this
114
     */
115
    public function setLibSerie(string $libSerie): Serie
116
    {
117
        $this->libSerie = $libSerie;
118
        return $this;
119
    }
120
121
    /**
122
     * @return string
123
     */
124
    public function getLibSerie(): string
125
    {
126
        return $this->libSerie;
127
    }
128
129
    /**
130
     * Set id
131
     * @param integer $id
132
     * @return $this
133
     */
134
    public function setId(int $id): Serie
135
    {
136
        $this->id = $id;
137
        return $this;
138
    }
139
140
    /**
141
     * Get id
142
     * @return int|null
143
     */
144
    public function getId(): ?int
145
    {
146
        return $this->id;
147
    }
148
149
    /**
150
     * Set status
151
     * @param string $status
152
     * @return $this
153
     */
154
    public function setStatus(string $status): Serie
155
    {
156
        $this->status = $status;
157
158
        return $this;
159
    }
160
161
    /**
162
     * Get status
163
     *
164
     * @return SerieStatus
165
     */
166
    public function getStatus(): SerieStatus
167
    {
168
        return new SerieStatus($this->status);
169
    }
170
171
    /**
172
     * @return mixed
173
     */
174
    public function getGames()
175
    {
176
        return $this->games;
177
    }
178
179
    /**
180
     * @param $badge
181
     */
182
    public function setBadge($badge = null): void
183
    {
184
        $this->badge = $badge;
185
    }
186
187
    /**
188
     * Get idBadge
189
     * @return Badge|null
190
     */
191
    public function getBadge(): ?Badge
192
    {
193
        return $this->badge;
194
    }
195
196
    /**
197
     * Returns an array of the fields used to generate the slug.
198
     * @return string[]
199
     */
200
    public function getSluggableFields(): array
201
    {
202
        return ['defaultName'];
203
    }
204
}
205