1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Loevgaard\SyliusBarcodePlugin\Model; |
6
|
|
|
|
7
|
|
|
use DateTime; |
8
|
|
|
use DateTimeInterface; |
9
|
|
|
use Doctrine\ORM\Mapping as ORM; |
10
|
|
|
|
11
|
|
|
trait ProductVariantTrait |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @ORM\Column(type="string", name="barcode", nullable=true) |
15
|
|
|
* |
16
|
|
|
* @var string|null |
17
|
|
|
*/ |
18
|
|
|
protected $barcode; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* The date where the barcode was checked |
22
|
|
|
* |
23
|
|
|
* @ORM\Column(type="datetime", name="barcode_checked", nullable=true) |
24
|
|
|
* |
25
|
|
|
* @var DateTimeInterface|null |
26
|
|
|
*/ |
27
|
|
|
protected $barcodeChecked; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @ORM\Column(type="boolean", name="barcode_valid", nullable=true) |
31
|
|
|
* |
32
|
|
|
* @var bool |
33
|
|
|
*/ |
34
|
|
|
protected $barcodeValid = false; |
35
|
|
|
|
36
|
|
|
public function getBarcode(): ?string |
37
|
|
|
{ |
38
|
|
|
return $this->barcode; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function setBarcode(?string $barcode): void |
42
|
|
|
{ |
43
|
|
|
$this->barcode = $barcode; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function isBarcodeChecked(): bool |
47
|
|
|
{ |
48
|
|
|
return $this->barcodeChecked instanceof DateTimeInterface; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getBarcodeChecked(): ?DateTimeInterface |
52
|
|
|
{ |
53
|
|
|
return $this->barcodeChecked; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function setBarcodeChecked(?DateTimeInterface $barcodeChecked): void |
57
|
|
|
{ |
58
|
|
|
$this->barcodeChecked = $barcodeChecked; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function isBarcodeValid(): bool |
62
|
|
|
{ |
63
|
|
|
return $this->barcodeValid; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function setBarcodeValid(bool $barcodeValid): void |
67
|
|
|
{ |
68
|
|
|
$this->barcodeValid = $barcodeValid; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function markBarcodeAsChecked(bool $valid): void |
72
|
|
|
{ |
73
|
|
|
$this->barcodeChecked = new DateTime(); |
74
|
|
|
$this->barcodeValid = $valid; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|