RefreshToken::getUser()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Components Bundle Project
5
 *
6
 * (c) Daniel West <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentsBundle\RefreshToken;
15
16
use Symfony\Component\Security\Core\User\UserInterface;
17
18
/**
19
 * @author Vincent Chalamon <[email protected]>
20
 */
21
class RefreshToken
22
{
23
    protected ?\DateTimeInterface $createdAt = null;
24
    protected ?\DateTimeInterface $expiresAt = null;
25
    protected ?UserInterface $user = null;
26
    protected ?int $version = null;
27
28
    public function getCreatedAt(): ?\DateTimeInterface
29
    {
30
        return $this->createdAt;
31
    }
32
33
    /**
34
     * @return static
35
     */
36
    public function setCreatedAt(\DateTimeInterface $createdAt)
37
    {
38
        $this->createdAt = $createdAt;
39
40
        return $this;
41
    }
42
43
    public function getExpiresAt(): ?\DateTimeInterface
44
    {
45
        return $this->expiresAt;
46
    }
47
48
    /**
49
     * @return static
50
     */
51
    public function setExpiresAt(\DateTimeInterface $expiresAt)
52
    {
53
        $this->expiresAt = $expiresAt;
54
55
        return $this;
56
    }
57
58
    public function getUser(): ?UserInterface
59
    {
60
        return $this->user;
61
    }
62
63
    /**
64
     * @return static
65
     */
66
    public function setUser(UserInterface $user)
67
    {
68
        $this->user = $user;
69
70
        return $this;
71
    }
72
73
    public function isExpired(): bool
74
    {
75
        return new \DateTimeImmutable() > $this->expiresAt;
76
    }
77
}
78