ConfirmationTrait   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 64
c 0
b 0
f 0
wmc 7
lcom 2
cbo 0
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A isConfirmed() 0 4 1
A setConfirmed() 0 6 1
A getConfirmationToken() 0 4 1
A hasConfirmationToken() 0 4 1
A setConfirmationToken() 0 6 1
A getConfirmedAt() 0 4 1
A setConfirmedAt() 0 6 1
1
<?php
2
3
namespace Fousky\Traits\Confirmed;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * User account is `confirmed` OR `non-confirmed` (e.g. by email address).
9
 *
10
 * @author Lukáš Brzák <[email protected]>
11
 */
12
trait ConfirmationTrait
13
{
14
    /**
15
     * @var bool
16
     *
17
     * @ORM\Column(name="is_confirmed", type="boolean", nullable=false, options={"default":"0"})
18
     */
19
    protected $confirmed = false;
20
21
    /**
22
     * @var string|null
23
     *
24
     * @ORM\Column(name="confirmation_token", type="string", nullable=true)
25
     */
26
    protected $confirmationToken;
27
28
    /**
29
     * @var \DateTime|null
30
     *
31
     * @ORM\Column(name="confirmed_at", type="datetime", nullable=true)
32
     */
33
    protected $confirmedAt;
34
35
    public function isConfirmed(): bool
36
    {
37
        return $this->confirmed === true;
38
    }
39
40
    public function setConfirmed(bool $confirmed): self
41
    {
42
        $this->confirmed = $confirmed;
43
44
        return $this;
45
    }
46
47
    public function getConfirmationToken(): ?string
48
    {
49
        return $this->confirmationToken;
50
    }
51
52
    public function hasConfirmationToken(): bool
53
    {
54
        return $this->confirmationToken !== null;
55
    }
56
57
    public function setConfirmationToken(?string $confirmationToken): self
58
    {
59
        $this->confirmationToken = $confirmationToken;
60
61
        return $this;
62
    }
63
64
    public function getConfirmedAt(): ?\DateTime
65
    {
66
        return $this->confirmedAt;
67
    }
68
69
    public function setConfirmedAt(?\DateTime $confirmedAt): self
70
    {
71
        $this->confirmedAt = $confirmedAt;
72
73
        return $this;
74
    }
75
}
76