Token::setCreatedAt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DataFlowServer\Authentication\Entities;
5
6
use Doctrine\Common\Collections\Collection;
7
use Doctrine\ORM\Mapping as ORM;
8
use SlayerBirden\DataFlowServer\Domain\Entities\ClaimedResourceInterface;
9
use SlayerBirden\DataFlowServer\Domain\Entities\User;
10
11
/**
12
 * @ORM\Entity()
13
 * @ORM\Table(name="tokens")
14
 */
15
class Token implements ClaimedResourceInterface
16
{
17
    /**
18
     * @ORM\Id()
19
     * @ORM\GeneratedValue()
20
     * @ORM\Column(type="integer")
21
     * @var integer
22
     */
23
    private $id;
24
    /**
25
     * @ORM\Column(type="string", nullable=false, unique=true)
26
     * @var string
27
     */
28
    private $token;
29
    /**
30
     * @ORM\Column(type="boolean", nullable=false)
31
     * @var boolean
32
     */
33
    private $active = false;
34
    /**
35
     * @ORM\Column(type="datetime")
36
     * @var \DateTime
37
     */
38
    private $createdAt;
39
    /**
40
     * @ORM\Column(type="datetime", nullable=false)
41
     * @var \DateTime
42
     */
43
    private $due;
44
    /**
45
     * @ORM\ManyToOne(targetEntity="\SlayerBirden\DataFlowServer\Domain\Entities\User")
46
     * @ORM\JoinColumn(onDelete="CASCADE")
47
     * @var User
48
     */
49
    private $owner;
50
    /**
51
     * @ORM\OneToMany(targetEntity="\SlayerBirden\DataFlowServer\Authentication\Entities\Grant", mappedBy="token")
52
     * @var Grant[]|Collection
53
     */
54
    private $grants;
55
56
    /**
57
     * @return int
58
     */
59 30
    public function getId(): int
60
    {
61 30
        return $this->id;
62
    }
63
64
    /**
65
     * @return string
66
     */
67 30
    public function getToken(): string
68
    {
69 30
        return $this->token;
70
    }
71
72
    /**
73
     * @param string $token
74
     */
75 24
    public function setToken(string $token): void
76
    {
77 24
        $this->token = $token;
78 24
    }
79
80
    /**
81
     * @return bool
82
     */
83 142
    public function isActive(): bool
84
    {
85 142
        return $this->active;
86
    }
87
88
    /**
89
     * @param bool $active
90
     */
91 46
    public function setActive(bool $active): void
92
    {
93 46
        $this->active = $active;
94 46
    }
95
96
    /**
97
     * @return \DateTime
98
     */
99 30
    public function getCreatedAt(): \DateTime
100
    {
101 30
        return $this->createdAt;
102
    }
103
104
    /**
105
     * @param \DateTime $createdAt
106
     */
107 28
    public function setCreatedAt(\DateTime $createdAt): void
108
    {
109 28
        $this->createdAt = $createdAt;
110 28
    }
111
112
    /**
113
     * @return \DateTime
114
     */
115 140
    public function getDue(): \DateTime
116
    {
117 140
        return $this->due;
118
    }
119
120
    /**
121
     * @param \DateTime $due
122
     */
123 40
    public function setDue(\DateTime $due): void
124
    {
125 40
        $this->due = $due;
126 40
    }
127
128
    /**
129
     * @return User
130
     */
131 134
    public function getOwner(): User
132
    {
133 134
        return $this->owner;
134
    }
135
136
    /**
137
     * @param User $owner
138
     */
139 30
    public function setOwner(User $owner): void
140
    {
141 30
        $this->owner = $owner;
142 30
    }
143
144
    /**
145
     * @return Collection|Grant[]
146
     */
147 136
    public function getGrants(): Collection
148
    {
149 136
        return $this->grants;
150
    }
151
152
    /**
153
     * @param Collection|Grant[] $grants
154
     */
155 28
    public function setGrants(Collection $grants): void
156
    {
157 28
        $this->grants = $grants;
158 28
    }
159
}
160