Completed
Push — Recipes ( c99128 )
by Laurent
13:15
created

Article   A

Complexity

Total Complexity 29

Size/Duplication

Total Lines 461
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 29
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 461
rs 10

29 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getId() 0 4 1
A setName() 0 6 1
A getName() 0 4 1
A setPackaging() 0 6 1
A getPackaging() 0 4 1
A setPrice() 0 6 1
A getPrice() 0 4 1
A setQuantity() 0 6 1
A getQuantity() 0 4 1
A setMinstock() 0 6 1
A getMinstock() 0 4 1
A setSupplier() 0 6 1
A getSupplier() 0 4 1
A setUnitStorage() 0 6 1
A getUnitStorage() 0 4 1
A addZoneStorage() 0 6 1
A removeZoneStorage() 0 4 1
A getZoneStorages() 0 4 1
A setUnitWorking() 0 6 1
A getUnitWorking() 0 4 1
A setFamilyLog() 0 6 1
A getFamilyLog() 0 4 1
A setTva() 0 6 1
A getTva() 0 4 1
A setActive() 0 6 1
A isActive() 0 4 1
A getSlug() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
/**
4
 * Entité Article.
5
 *
6
 * PHP Version 5
7
 *
8
 * @author    Quétier Laurent <[email protected]>
9
 * @copyright 2014 Dev-Int GLSR
10
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
11
 *
12
 * @version GIT: <git_id>
13
 *
14
 * @link https://github.com/Dev-Int/glsr
15
 */
16
namespace AppBundle\Entity\Settings;
17
18
use Doctrine\ORM\Mapping as ORM;
19
use Symfony\Component\Validator\Constraints as Assert;
20
use Gedmo\Mapping\Annotation as Gedmo;
21
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
22
use Doctrine\Common\Collections\ArrayCollection;
23
24
use AppBundle\Entity\Settings\Supplier;
25
use AppBundle\Entity\Settings\Diverse\Unit;
26
use AppBundle\Entity\Settings\Diverse\ZoneStorage;
27
use AppBundle\Entity\Settings\Diverse\FamilyLog;
28
29
/**
30
 * Article.
31
 *
32
 * @category Entity
33
 *
34
 * @ORM\Table(name="gs_article")
35
 * @ORM\Entity(repositoryClass="AppBundle\Repository\Settings\ArticleRepository")
36
 * @UniqueEntity(fields="name", message="Ce nom d'article est déjà utilisé.")
37
 * @ORM\HasLifecycleCallbacks()
38
 */
39
class Article
40
{
41
    /**
42
     * @var int Id de l'article
43
     *
44
     * @ORM\Column(name="id", type="integer")
45
     * @ORM\Id
46
     * @ORM\GeneratedValue(strategy="AUTO")
47
     */
48
    private $id;
49
50
    /**
51
     * @var string intitulé de l'article
52
     *
53
     * @ORM\Column(name="name", type="string", length=255)
54
     * @Assert\NotBlank()
55
     * @Assert\Regex(
56
     *     pattern="'^\w+[^/]'",
57
     *     message="L'intitulé ne peut contenir que des lettres,
58
     *     chiffres et _ ou -"
59
     * )
60
     */
61
    private $name;
62
63
    /**
64
     * @var string|\AppBundle\Entity\Settings\Supplier Nom du fournisseur
65
     *
66
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Settings\Supplier")
67
     */
68
    private $supplier;
69
70
    /**
71
     * @var string|\AppBundle\Entity\Settings\Diverse\Unit Unité de stockage
72
     *
73
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Settings\Diverse\Unit")
74
     */
75
    private $unitStorage;
76
77
    /**
78
     * @var string|\AppBundle\Entity\Settings\Diverse\Unit Unité d'exploitation
79
     *
80
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Settings\Diverse\Unit")
81
     */
82
    private $unitWorking;
83
84
    /**
85
     * @var double Conditionement (quantité)
86
     *
87
     * @ORM\Column(name="packaging", type="decimal", precision=7, scale=3)
88
     * @Assert\Type(type="numeric",
89
     * message="La valeur {{ value }} n'est pas un type {{ type }} valide.")
90
     */
91
    private $packaging;
92
93
    /**
94
     * @var double prix de l'article
95
     *
96
     * @ORM\Column(name="price", type="decimal", precision=7, scale=3)
97
     * @Assert\Type(type="numeric",
98
     * message="La valeur {{ value }} n'est pas un type {{ type }} valide.")
99
     */
100
    private $price;
101
102
    /**
103
     * @var string|\AppBundle\Entity\Settings\Diverse\Tva Taux de TVA
104
     *
105
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Settings\Diverse\Tva")
106
     */
107
    private $tva;
108
109
    /**
110
     * @var double Quantité en stock
111
     *
112
     * @ORM\Column(name="quantity", type="decimal", precision=7, scale=3, options={"default":0})
113
     * @Assert\Type(type="numeric",
114
     * message="La valeur {{ value }} n'est pas un type {{ type }} valide.")
115
     */
116
    private $quantity;
117
118
    /**
119
     * @var double Stock minimum
120
     *
121
     * @ORM\Column(name="minstock", type="decimal", precision=7, scale=3)
122
     * @Assert\Type(type="numeric",
123
     * message="La valeur {{ value }} n'est pas un type {{ type }} valide.")
124
     */
125
    private $minstock;
126
127
    /**
128
     * @var \Doctrine\Common\Collections\ArrayCollection Zone(s) de stockage
129
     *
130
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Settings\Diverse\ZoneStorage")
131
     * @ORM\JoinTable(name="gs_article_zonestorage")
132
     * @Assert\NotBlank()
133
     */
134
    private $zoneStorages;
135
136
    /**
137
     * @var string|\AppBundle\Entity\Settings\Diverse\FamilyLog Famille logistique
138
     *
139
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Settings\Diverse\FamilyLog")
140
     * @Assert\NotBlank()
141
     */
142
    private $familyLog;
143
144
    /**
145
     * @var bool Activé/Désactivé
146
     *
147
     * @ORM\Column(name="active", type="boolean")
148
     */
149
    private $active;
150
151
    /**
152
     * @Gedmo\Slug(fields={"name"}, updatable=false)
153
     * @ORM\Column(length=128, unique=true)
154
     */
155
    private $slug;
156
157
    /**
158
     * Constructor.
159
     */
160
    public function __construct()
161
    {
162
        $this->zoneStorages = new ArrayCollection();
163
        $this->active = true;
164
        $this->quantity = 0.000;
165
    }
166
167
    /**
168
     * Get id.
169
     *
170
     * @return int
171
     */
172
    public function getId()
173
    {
174
        return $this->id;
175
    }
176
177
    /**
178
     * Set name.
179
     *
180
     * @param string $name Nom de l'article
181
     *
182
     * @return Article
183
     */
184
    public function setName($name)
185
    {
186
        $this->name = $name;
187
188
        return $this;
189
    }
190
191
    /**
192
     * Get name.
193
     *
194
     * @return string
195
     */
196
    public function getName()
197
    {
198
        return $this->name;
199
    }
200
201
    /**
202
     * Set packaging.
203
     *
204
     * @param double $packaging Conditionnement (quantité)
205
     *
206
     * @return Article
207
     */
208
    public function setPackaging($packaging)
209
    {
210
        $this->packaging = $packaging;
211
212
        return $this;
213
    }
214
215
    /**
216
     * Get packaging.
217
     *
218
     * @return double
219
     */
220
    public function getPackaging()
221
    {
222
        return $this->packaging;
223
    }
224
225
    /**
226
     * Set price.
227
     *
228
     * @param double $price prix de l'article
229
     *
230
     * @return Article
231
     */
232
    public function setPrice($price)
233
    {
234
        $this->price = $price;
235
236
        return $this;
237
    }
238
239
    /**
240
     * Get price.
241
     *
242
     * @return double
243
     */
244
    public function getPrice()
245
    {
246
        return $this->price;
247
    }
248
249
    /**
250
     * Set quantity.
251
     *
252
     * @param double $quantity quantité en stock
253
     *
254
     * @return Article
255
     */
256
    public function setQuantity($quantity)
257
    {
258
        $this->quantity = $quantity;
259
260
        return $this;
261
    }
262
263
    /**
264
     * Get quantity.
265
     *
266
     * @return double
267
     */
268
    public function getQuantity()
269
    {
270
        return $this->quantity;
271
    }
272
273
    /**
274
     * Set minstock.
275
     *
276
     * @param double $minstock stock minimum
277
     *
278
     * @return Article
279
     */
280
    public function setMinstock($minstock)
281
    {
282
        $this->minstock = $minstock;
283
284
        return $this;
285
    }
286
287
    /**
288
     * Get minstock.
289
     *
290
     * @return double
291
     */
292
    public function getMinstock()
293
    {
294
        return $this->minstock;
295
    }
296
297
    /**
298
     * Set supplier.
299
     *
300
     * @param null|\AppBundle\Entity\Settings\Supplier $supplier Fournisseur de l'article
301
     *
302
     * @return Article
303
     */
304
    public function setSupplier(Supplier $supplier = null)
305
    {
306
        $this->supplier = $supplier;
307
308
        return $this;
309
    }
310
311
    /**
312
     * Get supplier.
313
     *
314
     * @return string|\AppBundle\Entity\Settings\Supplier
315
     */
316
    public function getSupplier()
317
    {
318
        return $this->supplier;
319
    }
320
321
    /**
322
     * Set unitStorage.
323
     *
324
     * @param null|\AppBundle\Entity\Settings\Diverse\Unit $unitStorage Unité de stockage
325
     *
326
     * @return Article
327
     */
328
    public function setUnitStorage(Unit $unitStorage = null)
329
    {
330
        $this->unitStorage = $unitStorage;
331
332
        return $this;
333
    }
334
335
    /**
336
     * Get unitStorage.
337
     *
338
     * @return string|\AppBundle\Entity\Settings\Diverse\Unit
339
     */
340
    public function getUnitStorage()
341
    {
342
        return $this->unitStorage;
343
    }
344
345
    /**
346
     * Add zoneStorage.
347
     *
348
     * @param \AppBundle\Entity\Settings\Diverse\ZoneStorage
349
     * $zoneStorages Zone(s) de stockage
350
     *
351
     * @return Article
352
     */
353
    public function addZoneStorage(ZoneStorage $zoneStorages)
354
    {
355
        $this->zoneStorages[] = $zoneStorages;
356
357
        return $this;
358
    }
359
360
    /**
361
     * Remove zoneStorage.
362
     *
363
     * @param \AppBundle\Entity\Settings\Diverse\ZoneStorage $zoneStorages Zone de stockage à supprimer
364
     *
365
     * @return \Doctrine\Common\Collections\ArrayCollection|null
366
     */
367
    public function removeZoneStorage(ZoneStorage $zoneStorages)
368
    {
369
        $this->zoneStorages->removeElement($zoneStorages);
370
    }
371
372
    /**
373
     * Get zoneStorage.
374
     *
375
     * @return \Doctrine\Common\Collections\ArrayCollection
376
     */
377
    public function getZoneStorages()
378
    {
379
        return $this->zoneStorages;
380
    }
381
382
    /**
383
     * Set unitWorking
384
     *
385
     * @param \AppBundle\Entity\Settings\Diverse\Unit $unitWorking
386
     * @return Article
387
     */
388
    public function setUnitWorking(Unit $unitWorking = null)
389
    {
390
        $this->unitWorking = $unitWorking;
391
392
        return $this;
393
    }
394
395
    /**
396
     * Get unitWorking
397
     *
398
     * @return \AppBundle\Entity\Settings\Diverse\UnitWorking
399
     */
400
    public function getUnitWorking()
401
    {
402
        return $this->unitWorking;
403
    }
404
405
    /**
406
     * Set familyLog.
407
     *
408
     * @param null|\AppBundle\Entity\Settings\Diverse\FamilyLog $familyLog Famille Logistique
409
     *
410
     * @return Article
411
     */
412
    public function setFamilyLog(FamilyLog $familyLog = null)
413
    {
414
        $this->familyLog = $familyLog;
415
416
        return $this;
417
    }
418
419
    /**
420
     * Get familyLog.
421
     *
422
     * @return \AppBundle\Entity\Settings\Diverse\FamilyLog
423
     */
424
    public function getFamilyLog()
425
    {
426
        return $this->familyLog;
427
    }
428
429
    /**
430
     * Set tva
431
     *
432
     * @param \AppBundle\Entity\Settings\Diverse\Tva $tva
433
     * @return Article
434
     */
435
    public function setTva(\AppBundle\Entity\Settings\Diverse\Tva $tva = null)
436
    {
437
        $this->tva = $tva;
438
439
        return $this;
440
    }
441
442
    /**
443
     * Get tva
444
     *
445
     * @return \AppBundle\Entity\Settings\Diverse\Tva
446
     */
447
    public function getTva()
448
    {
449
        return $this->tva;
450
    }
451
452
    /**
453
     * Set active.
454
     *
455
     * @param bool $active Activé/Désactivé
456
     *
457
     * @return Article
458
     */
459
    public function setActive($active)
460
    {
461
        $this->active = $active;
462
463
        return $this;
464
    }
465
466
    /**
467
     * Is active
468
     *
469
     * @return boolean
470
     */
471
    public function isActive()
472
    {
473
        return $this->active;
474
    }
475
476
    /**
477
     * Get slug
478
     *
479
     * @return string
480
     */
481
    public function getSlug()
482
    {
483
        return $this->slug;
484
    }
485
486
    /**
487
     * Cette méthode permet de faire "echo $article".
488
     * <p>Ainsi, pour "afficher" $article,
489
     * PHP affichera en réalité le retour de cette méthode.<br />
490
     * Ici, le nom, donc "echo $article"
491
     * est équivalent à "echo $article->getName()".</p>
492
     *
493
     * @return string name
494
     */
495
    public function __toString()
496
    {
497
        return $this->name;
498
    }
499
}
500