Passed
Pull Request — master (#94)
by Daniel
06:15
created

RefreshToken   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 54
ccs 0
cts 17
cp 0
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getCreatedAt() 0 3 1
A setCreatedAt() 0 5 1
A isExpired() 0 3 1
A getUser() 0 3 1
A setUser() 0 5 1
A getExpiresAt() 0 3 1
A setExpiresAt() 0 5 1
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