Completed
Pull Request — master (#924)
by
unknown
02:27
created

TokenEntityTrait::getExpiryDateTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * @author      Alex Bilbie <[email protected]>
4
 * @copyright   Copyright (c) Alex Bilbie
5
 * @license     http://mit-license.org/
6
 *
7
 * @link        https://github.com/thephpleague/oauth2-server
8
 */
9
10
namespace League\OAuth2\Server\Entities\Traits;
11
12
use League\OAuth2\Server\Entities\ClientEntityInterface;
13
use League\OAuth2\Server\Entities\ScopeEntityInterface;
14
15
trait TokenEntityTrait
16
{
17
    /**
18
     * @var ScopeEntityInterface[]
19
     */
20
    protected $scopes = [];
21
22
    /**
23
     * @var \DateTime
24
     */
25
    protected $expiryDateTime;
26
27
    /**
28
     * @var string|int|null
29
     */
30
    protected $userIdentifier;
31
32
    /**
33
     * @var ClientEntityInterface
34
     */
35
    protected $client;
36
37
    /**
38
     * Associate a scope with the token.
39
     *
40
     * @param ScopeEntityInterface $scope
41
     */
42 3
    public function addScope(ScopeEntityInterface $scope)
43
    {
44 3
        $this->scopes[$scope->getIdentifier()] = $scope;
45 3
    }
46
47
    /**
48
     * Return an array of scopes associated with the token.
49
     *
50
     * @return ScopeEntityInterface[]
51
     */
52 2
    public function getScopes()
53
    {
54 2
        return array_values($this->scopes);
55
    }
56
57
    /**
58
     * Get the token's expiry date time.
59
     *
60
     * @return \DateTime
61
     */
62
    public function getExpiryDateTime()
63
    {
64
        return $this->expiryDateTime;
65
    }
66
67
    /**
68
     * Set the date time when the token expires.
69
     *
70
     * @param \DateTime $dateTime
71
     */
72 5
    public function setExpiryDateTime(\DateTime $dateTime)
73
    {
74 5
        $this->expiryDateTime = $dateTime;
75 5
    }
76
77
    /**
78
     * Set the identifier of the user associated with the token.
79
     *
80
     * @param string|int|null $identifier The identifier of the user
81
     */
82 5
    public function setUserIdentifier($identifier)
83
    {
84 5
        $this->userIdentifier = $identifier;
85 5
    }
86
87
    /**
88
     * Get the token user's identifier.
89
     *
90
     * @return string|int|null
91
     */
92 2
    public function getUserIdentifier()
93
    {
94 2
        return $this->userIdentifier;
95
    }
96
97
    /**
98
     * Get the client that the token was issued to.
99
     *
100
     * @return ClientEntityInterface
101
     */
102 2
    public function getClient()
103
    {
104 2
        return $this->client;
105
    }
106
107
    /**
108
     * Set the client that the token was issued to.
109
     *
110
     * @param ClientEntityInterface $client
111
     */
112 5
    public function setClient(ClientEntityInterface $client)
113
    {
114 5
        $this->client = $client;
115 5
    }
116
}
117