Passed
Pull Request — master (#94)
by Daniel
08:24 queued 01:42
created

RefreshToken::getExpiredAt()   A

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
27
    public function getCreatedAt(): ?\DateTimeInterface
28
    {
29
        return $this->createdAt;
30
    }
31
32
    /**
33
     * @return static
34
     */
35
    public function setCreatedAt(\DateTimeInterface $createdAt)
36
    {
37
        $this->createdAt = $createdAt;
38
39
        return $this;
40
    }
41
42
    public function getExpiresAt(): ?\DateTimeInterface
43
    {
44
        return $this->expiresAt;
45
    }
46
47
    /**
48
     * @return static
49
     */
50
    public function setExpiresAt(\DateTimeInterface $expiresAt)
51
    {
52
        $this->expiresAt = $expiresAt;
53
54
        return $this;
55
    }
56
57
    public function getUser(): ?UserInterface
58
    {
59
        return $this->user;
60
    }
61
62
    /**
63
     * @return static
64
     */
65
    public function setUser(UserInterface $user)
66
    {
67
        $this->user = $user;
68
69
        return $this;
70
    }
71
72
    public function isExpired(): bool
73
    {
74
        return new \DateTimeImmutable() > $this->expiresAt;
75
    }
76
}
77