Completed
Push — master ( cba565...f8bef5 )
by Joachim
09:07 queued 03:26
created

ProductVariantTrait::setBarcodeValid()   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 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Loevgaard\SyliusBarcodePlugin\Model;
6
7
use DateTime;
8
9
trait ProductVariantTrait
10
{
11
    /**
12
     * @var string|null
13
     */
14
    protected $barcode;
15
16
    /**
17
     * The date where the barcode was checked
18
     *
19
     * @var DateTime|null
20
     */
21
    protected $barcodeChecked;
22
23
    /**
24
     * @var bool
25
     */
26
    protected $barcodeValid = false;
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function getBarcode(): ?string
32
    {
33
        return $this->barcode;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function setBarcode(?string $barcode): void
40
    {
41
        $this->barcode = $barcode;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function isBarcodeChecked(): bool
48
    {
49
        return $this->barcodeChecked instanceof DateTime;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function getBarcodeChecked(): ?DateTime
56
    {
57
        return $this->barcodeChecked;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function setBarcodeChecked(?DateTime $barcodeChecked): void
64
    {
65
        $this->barcodeChecked = $barcodeChecked;
66
    }
67
68
    /**
69
     * @return bool
70
     */
71
    public function isBarcodeValid(): bool
72
    {
73
        return $this->barcodeValid;
74
    }
75
76
    /**
77
     * @param bool $barcodeValid
78
     */
79
    public function setBarcodeValid(bool $barcodeValid): void
80
    {
81
        $this->barcodeValid = $barcodeValid;
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87
    public function markBarcodeAsChecked(bool $valid): void
88
    {
89
        $this->barcodeChecked = new DateTime();
90
        $this->barcodeValid = $valid;
91
    }
92
}
93