Completed
Push — Recipes ( c0466a...7632b6 )
by Laurent
04:22
created

Article::getDeleteAt()   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
/**
4
 * Entity Article.
5
 *
6
 * PHP Version 7
7
 *
8
 * @author    Quétier Laurent <[email protected]>
9
 * @copyright 2018 Dev-Int GLSR
10
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
11
 *
12
 * @version GIT: $Id$
13
 *
14
 * @see https://github.com/Dev-Int/glsr
15
 */
16
17
namespace App\Entity\Settings;
18
19
use Doctrine\ORM\Mapping as ORM;
20
use Symfony\Component\Validator\Constraints as Assert;
21
use Gedmo\Mapping\Annotation as Gedmo;
22
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
23
use Doctrine\Common\Collections\ArrayCollection;
24
use App\Entity\Settings\Diverse\Unit;
25
use App\Entity\Settings\Diverse\Tva;
26
use App\Entity\Settings\Diverse\FamilyLog;
27
use App\Entity\Settings\Diverse\ZoneStorage;
28
29
/**
30
 * Article.
31
 *
32
 * @category Entity
33
 *
34
 * @ORM\Table(name="app_article")
35
 * @ORM\Entity(repositoryClass="App\Repository\Settings\ArticleRepository")
36
 * @UniqueEntity(fields="name", message="This article name is already used.")
37
 * @ORM\HasLifecycleCallbacks()
38
 */
39
class Article
40
{
41
    /**
42
     * @var int Id of the 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 title of the article
52
     *
53
     * @ORM\Column(name="name", type="string", length=255)
54
     * @Assert\NotBlank()
55
     * @Assert\Regex(
56
     *     pattern="'^\w+[^/]'",
57
     *     message="The title can only contain letters,
58
     * digits and _ or -"
59
     * )
60
     */
61
    private $name;
62
63
    /**
64
     * @var string|\App\Entity\Settings\Supplier Name of supplier
65
     *
66
     * @ORM\ManyToOne(targetEntity="App\Entity\Settings\Supplier", inversedBy="articles")
67
     */
68
    private $supplier;
69
70
    /**
71
     * @var string|\App\Entity\Settings\Diverse\Unit Storage unit
72
     *
73
     * @ORM\ManyToOne(targetEntity="App\Entity\Settings\Diverse\Unit")
74
     */
75
    private $unitStorage;
76
77
    /**
78
     * @var string|\App\Entity\Settings\Diverse\Unit Working unit
79
     *
80
     * @ORM\ManyToOne(targetEntity="App\Entity\Settings\Diverse\Unit")
81
     */
82
    private $unitWorking;
83
84
    /**
85
     * @var float Packaging (quantity)
86
     *
87
     * @ORM\Column(name="packaging", type="decimal", precision=7, scale=3)
88
     * @Assert\Type(type="numeric",
89
     * message="The value {{value}} is not a valid type {{type}}.")
90
     */
91
    private $packaging;
92
93
    /**
94
     * @var float price of the article
95
     *
96
     * @ORM\Column(name="price", type="decimal", precision=7, scale=3)
97
     * @Assert\Type(type="numeric",
98
     * message="The value {{value}} is not a valid type {{type}}.")
99
     */
100
    private $price;
101
102
    /**
103
     * @var string|\App\Entity\Settings\Diverse\Tva VAT rate
104
     *
105
     * @ORM\ManyToOne(targetEntity="App\Entity\Settings\Diverse\Tva")
106
     */
107
    private $tva;
108
109
    /**
110
     * @var float Quantity in stock
111
     *
112
     * @ORM\Column(name="quantity", type="decimal", precision=7, scale=3, nullable=true, options={"default":0})
113
     * @Assert\Type(type="numeric",
114
     * message="The value {{value}} is not a valid type {{type}}.")
115
     */
116
    private $quantity;
117
118
    /**
119
     * @var float Minimum stock
120
     *
121
     * @ORM\Column(name="minstock", type="decimal", precision=7, scale=3)
122
     * @Assert\Type(type="numeric",
123
     * message="The value {{value}} is not a valid type {{type}}.")
124
     */
125
    private $minstock;
126
127
    /**
128
     * @var \Doctrine\Common\Collections\ArrayCollection Storage area (s)
129
     *
130
     * @ORM\ManyToMany(targetEntity="App\Entity\Settings\Diverse\ZoneStorage")
131
     * @ORM\JoinTable(name="app_article_zonestorage")
132
     * @Assert\NotBlank()
133
     */
134
    private $zoneStorages;
135
136
    /**
137
     * @var string|\App\Entity\Settings\Diverse\FamilyLog Logistic family
138
     *
139
     * @ORM\ManyToOne(targetEntity="App\Entity\Settings\Diverse\FamilyLog")
140
     * @Assert\NotBlank()
141
     */
142
    private $familyLog;
143
144
    /**
145
     * @var bool On / Off
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
     * @var \DateTimeInterface Created date
159
     * @ORM\Column(name="create_at", type="datetime")
160
     */
161
    private $createAt;
162
163
    /**
164
     * @var \DateTimeInterface|null Updated date
165
     * @ORM\Column(name="update_at", type="datetime", nullable=true)
166
     */
167
    private $updateAt;
168
169
    /**
170
     * @var \DateTimeInterface|null Deleted date
171
     * @ORM\Column(name="delete_at", type="datetime", nullable=true)
172
     */
173
    private $deleteAt;
174
175
    /**
176
     * Constructor.
177
     */
178
    public function __construct()
179
    {
180
        $this->zoneStorages = new ArrayCollection();
181
        $this->active = true;
182
        $this->quantity = 0.000;
183
        $this->createAt = new \DateTime();
184
        $this->deleteAt = new \DateTime('3000-12-31');
185
    }
186
187
    /**
188
     * Get id.
189
     *
190
     * @return int
191
     */
192
    public function getId()
193
    {
194
        return $this->id;
195
    }
196
197
    /**
198
     * Set name.
199
     *
200
     * @param string $name Article name
201
     *
202
     * @return Article
203
     */
204
    public function setName($name)
205
    {
206
        $this->name = $name;
207
208
        return $this;
209
    }
210
211
    /**
212
     * Get name.
213
     *
214
     * @return string
215
     */
216
    public function getName()
217
    {
218
        return $this->name;
219
    }
220
221
    /**
222
     * Set packaging.
223
     *
224
     * @param float $packaging Packaging (quantity)
225
     *
226
     * @return Article
227
     */
228
    public function setPackaging($packaging)
229
    {
230
        $this->packaging = $packaging;
231
232
        return $this;
233
    }
234
235
    /**
236
     * Get packaging.
237
     *
238
     * @return float
239
     */
240
    public function getPackaging()
241
    {
242
        return $this->packaging;
243
    }
244
245
    /**
246
     * Set price.
247
     *
248
     * @param float $price price of the article
249
     *
250
     * @return Article
251
     */
252
    public function setPrice($price)
253
    {
254
        $this->price = $price;
255
256
        return $this;
257
    }
258
259
    /**
260
     * Get price.
261
     *
262
     * @return float
263
     */
264
    public function getPrice()
265
    {
266
        return $this->price;
267
    }
268
269
    /**
270
     * Set quantity.
271
     *
272
     * @param float $quantity quantity in stock
273
     *
274
     * @return Article
275
     */
276
    public function setQuantity($quantity)
277
    {
278
        $this->quantity = $quantity;
279
280
        return $this;
281
    }
282
283
    /**
284
     * Get quantity.
285
     *
286
     * @return float
287
     */
288
    public function getQuantity()
289
    {
290
        return $this->quantity;
291
    }
292
293
    /**
294
     * Set minstock.
295
     *
296
     * @param float $minstock Minimum stock
297
     *
298
     * @return Article
299
     */
300
    public function setMinstock($minstock)
301
    {
302
        $this->minstock = $minstock;
303
304
        return $this;
305
    }
306
307
    /**
308
     * Get minstock.
309
     *
310
     * @return float
311
     */
312
    public function getMinstock()
313
    {
314
        return $this->minstock;
315
    }
316
317
    /**
318
     * Set supplier.
319
     *
320
     * @param \App\Entity\Settings\Supplier|null $supplier Supplier of the article
321
     *
322
     * @return Article
323
     */
324
    public function setSupplier(Supplier $supplier = null)
325
    {
326
        $this->supplier = $supplier;
327
328
        return $this;
329
    }
330
331
    /**
332
     * Get supplier.
333
     *
334
     * @return string|\App\Entity\Settings\Supplier
335
     */
336
    public function getSupplier()
337
    {
338
        return $this->supplier;
339
    }
340
341
    /**
342
     * Set unitStorage.
343
     *
344
     * @param \App\Entity\Settings\Diverse\Unit|null $unitStorage Storage unit
345
     *
346
     * @return Article
347
     */
348
    public function setUnitStorage(Unit $unitStorage = null)
349
    {
350
        $this->unitStorage = $unitStorage;
351
352
        return $this;
353
    }
354
355
    /**
356
     * Get unitStorage.
357
     *
358
     * @return string|\App\Entity\Settings\Diverse\Unit
359
     */
360
    public function getUnitStorage()
361
    {
362
        return $this->unitStorage;
363
    }
364
365
    /**
366
     * Add zoneStorage.
367
     *
368
     * @param \App\Entity\Settings\Diverse\ZoneStorage
369
     * $zoneStorages Stockage area (s)
370
     *
371
     * @return Article
372
     */
373
    public function addZoneStorage(ZoneStorage $zoneStorages)
374
    {
375
        $this->zoneStorages[] = $zoneStorages;
376
377
        return $this;
378
    }
379
380
    /**
381
     * Remove zoneStorage.
382
     *
383
     * @param \App\Entity\Settings\Diverse\ZoneStorage $zoneStorages Storage area to delete
384
     *
385
     * @return \Doctrine\Common\Collections\ArrayCollection|null
386
     */
387
    public function removeZoneStorage(ZoneStorage $zoneStorages)
388
    {
389
        $this->zoneStorages->removeElement($zoneStorages);
390
    }
391
392
    /**
393
     * Get zoneStorage.
394
     *
395
     * @return \Doctrine\Common\Collections\ArrayCollection
396
     */
397
    public function getZoneStorages()
398
    {
399
        return $this->zoneStorages;
400
    }
401
402
    /**
403
     * Set unitWorking.
404
     *
405
     * @param \App\Entity\Settings\Diverse\Unit $unitWorking
406
     *
407
     * @return Article
408
     */
409
    public function setUnitWorking(Unit $unitWorking = null)
410
    {
411
        $this->unitWorking = $unitWorking;
412
413
        return $this;
414
    }
415
416
    /**
417
     * Get unitWorking.
418
     *
419
     * @return \App\Entity\Settings\Diverse\UnitWorking
0 ignored issues
show
Bug introduced by
The type App\Entity\Settings\Diverse\UnitWorking 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...
420
     */
421
    public function getUnitWorking()
422
    {
423
        return $this->unitWorking;
424
    }
425
426
    /**
427
     * Set familyLog.
428
     *
429
     * @param \App\Entity\Settings\Diverse\FamilyLog|null $familyLog Logistic family
430
     *
431
     * @return Article
432
     */
433
    public function setFamilyLog(FamilyLog $familyLog = null)
434
    {
435
        $this->familyLog = $familyLog;
436
437
        return $this;
438
    }
439
440
    /**
441
     * Get familyLog.
442
     *
443
     * @return \App\Entity\Settings\Diverse\FamilyLog
444
     */
445
    public function getFamilyLog()
446
    {
447
        return $this->familyLog;
448
    }
449
450
    /**
451
     * Set tva.
452
     *
453
     * @param \App\Entity\Settings\Diverse\Tva $tva
454
     *
455
     * @return Article
456
     */
457
    public function setTva(Tva $tva = null)
458
    {
459
        $this->tva = $tva;
460
461
        return $this;
462
    }
463
464
    /**
465
     * Get tva.
466
     *
467
     * @return \App\Entity\Settings\Diverse\Tva
468
     */
469
    public function getTva()
470
    {
471
        return $this->tva;
472
    }
473
474
    /**
475
     * Set active.
476
     *
477
     * @param bool $active On / Off
478
     *
479
     * @return Article
480
     */
481
    public function setActive($active)
482
    {
483
        $this->active = $active;
484
485
        return $this;
486
    }
487
488
    /**
489
     * Is active.
490
     *
491
     * @return bool
492
     */
493
    public function isActive()
494
    {
495
        return $this->active;
496
    }
497
498
    /**
499
     * Get slug.
500
     *
501
     * @return string
502
     */
503
    public function getSlug()
504
    {
505
        return $this->slug;
506
    }
507
508
    /**
509
     * This method allows to make "echo $article".
510
     * <p> So, to "show" $article,
511
     * PHP will actually show the return of this method. <br />
512
     * Here, the name, so "echo $article"
513
     * is equivalent to "echo $article->getName()". </p>.
514
     *
515
     * @return string name
516
     */
517
    public function __toString()
518
    {
519
        return $this->name;
520
    }
521
522
    public function setSlug(string $slug): self
523
    {
524
        $this->slug = $slug;
525
526
        return $this;
527
    }
528
529
    /**
530
     * Get Create at.
531
     *
532
     * @return \DateTimeInterface
533
     */
534
    public function getCreateAt()
535
    {
536
        return $this->createAt;
537
    }
538
539
    public function setCreateAt(\DateTimeInterface $createAt): self
540
    {
541
        $this->createAt = $createAt;
542
543
        return $this;
544
    }
545
546
    /**
547
     * Get Update at.
548
     *
549
     * @return \DateTimeInterface
550
     */
551
    public function getUpdateAt()
552
    {
553
        return $this->updateAt;
554
    }
555
556
    public function setUpdateAt(\DateTimeInterface $updateAt): self
557
    {
558
        $this->updateAt = $updateAt;
559
560
        return $this;
561
    }
562
563
    /**
564
     * Get Delete at.
565
     *
566
     * @return \DateTimeInterface
567
     */
568
    public function getDeleteAt()
569
    {
570
        return $this->deleteAt;
571
    }
572
573
    public function setDeleteAt(\DateTimeInterface $deleteAt = null): self
574
    {
575
        if (null === $deleteAt) {
576
            $this->deleteAt = new \DateTime();
577
            date_date_set($this->deleteAt, date('Y') + 4, 12, 31);
578
        } else {
579
            $this->deleteAt = $deleteAt;
580
        }
581
582
        return $this;
583
    }
584
}
585