Total Complexity | 5 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | trait ConfirmableTrait |
||
15 | { |
||
16 | /** |
||
17 | * @var \DateTime|null |
||
18 | */ |
||
19 | protected $confirmedAt; |
||
20 | |||
21 | /** |
||
22 | * Get confirmedAt. |
||
23 | * |
||
24 | * @return \DateTime|null |
||
25 | */ |
||
26 | public function getConfirmedAt(): ?\DateTime |
||
27 | { |
||
28 | return $this->confirmedAt; |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Set confirmedAt. |
||
33 | * |
||
34 | * @param \DateTime|null $confirmedAt |
||
35 | */ |
||
36 | public function setConfirmedAt(?\DateTime $confirmedAt): void |
||
37 | { |
||
38 | $this->confirmedAt = $confirmedAt; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Set confirmed. |
||
43 | * |
||
44 | * @param bool $confirmed |
||
45 | */ |
||
46 | public function setConfirmed(bool $confirmed): void |
||
47 | { |
||
48 | if ($confirmed) { |
||
49 | $this->setConfirmedAt(new \DateTime()); |
||
50 | } else { |
||
51 | $this->setConfirmedAt(null); |
||
52 | } |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Get confirmed. |
||
57 | * |
||
58 | * @return bool |
||
59 | */ |
||
60 | public function isConfirmed(): bool |
||
63 | } |
||
64 | } |
||
65 |