Completed
Push — master ( d14457...da0e1e )
by Derek Stephen
25:25 queued 19:55
created

AuthCode   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 163
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 13
eloc 22
dl 0
loc 163
ccs 0
cts 32
cp 0
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A setUserIdentifier() 0 3 1
A setIdentifier() 0 3 1
A setRedirectUri() 0 3 1
A setClient() 0 3 1
A getScopes() 0 3 1
A setExpiryDateTime() 0 3 1
A getIdentifier() 0 3 1
A getExpiryDateTime() 0 3 1
A getUserIdentifier() 0 3 1
A __construct() 0 3 1
A addScope() 0 4 1
A getClient() 0 3 1
A getRedirectUri() 0 3 1
1
<?php
2
3
namespace OAuth;
4
5
use DateTime;
6
use Doctrine\Common\Collections\ArrayCollection;
7
use Doctrine\ORM\Mapping as ORM;
8
use League\OAuth2\Server\Entities\AuthCodeEntityInterface;
9
use League\OAuth2\Server\Entities\ClientEntityInterface;
10
use League\OAuth2\Server\Entities\ScopeEntityInterface;
11
12
/**
13
 * @ORM\Entity(repositoryClass="OAuth\Repository\AuthCodeRepository")
14
 * @ORM\Table(name="AuthCode")
15
 */
16
class AuthCode implements AuthCodeEntityInterface
17
{
18
19
    /**
20
     * @var null|string
21
     * @ORM\Column(type="string", length=255, nullable=true)
22
     */
23
    protected $redirectUri;
24
25
    /**
26
     * @var ArrayCollection $scopes
27
     */
28
    protected $scopes;
29
30
    /**
31
     * @var DateTime
32
     * @ORM\Column(type="datetime",nullable=true)
33
     */
34
    protected $expiryDateTime;
35
36
    /**
37
     * @var OAuthUser
38
     * @ORM\OneToOne(targetEntity="OAuth\OAuthUser")
39
     * @ORM\JoinColumn(name="client", referencedColumnName="id")
40
     */
41
    protected $userIdentifier;
42
43
    /**
44
     * @var ClientEntityInterface
45
     * @ORM\ManyToOne(targetEntity="OAuth\Client")
46
     * @ORM\JoinColumn(name="client", referencedColumnName="id")
47
     */
48
    protected $client;
49
50
    /**
51
     * @var string
52
     * @ORM\Column(type="text", nullable=false)
53
     */
54
    protected $identifier;
55
56
    /**
57
     * @var int
58
     * @ORM\Id
59
     * @ORM\Column(type="integer", nullable=false)
60
     * @ORM\GeneratedValue
61
     */
62
    protected $id;
63
64
    public function __construct()
65
    {
66
        $this->scopes = new ArrayCollection();
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function getIdentifier()
73
    {
74
        return $this->identifier;
75
    }
76
77
    /**
78
     * @param string $identifier
79
     */
80
    public function setIdentifier($identifier)
81
    {
82
        $this->identifier = $identifier;
83
    }
84
85
    /**
86
     * @param ScopeEntityInterface $scope
87
     * @return $this
88
     */
89
    public function addScope(ScopeEntityInterface $scope)
90
    {
91
        $this->scopes->add($scope);
92
        return $this;
93
    }
94
95
    /**
96
     * Return an array of scopes associated with the token.
97
     *
98
     * @return ScopeEntityInterface[]
99
     */
100
    public function getScopes()
101
    {
102
        return $this->scopes->toArray();
103
    }
104
105
    /**
106
     * Get the token's expiry date time.
107
     *
108
     * @return DateTime
109
     */
110
    public function getExpiryDateTime()
111
    {
112
        return $this->expiryDateTime;
113
    }
114
115
    /**
116
     * Set the date time when the token expires.
117
     *
118
     * @param DateTime $dateTime
119
     */
120
    public function setExpiryDateTime(DateTime $dateTime)
121
    {
122
        $this->expiryDateTime = $dateTime;
123
    }
124
125
    /**
126
     * Set the identifier of the user associated with the token.
127
     *
128
     * @param User $identifier The identifier of the user
0 ignored issues
show
Bug introduced by
The type OAuth\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
129
     */
130
    public function setUserIdentifier($identifier)
131
    {
132
        $this->userIdentifier = $identifier;
133
    }
134
135
    /**
136
     * Get the token user's identifier.
137
     *
138
     * @return User
139
     */
140
    public function getUserIdentifier()
141
    {
142
        return $this->userIdentifier;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->userIdentifier returns the type OAuth\OAuthUser which is incompatible with the documented return type OAuth\User.
Loading history...
143
    }
144
145
    /**
146
     * Get the client that the token was issued to.
147
     *
148
     * @return ClientEntityInterface
149
     */
150
    public function getClient()
151
    {
152
        return $this->client;
153
    }
154
155
    /**
156
     * Set the client that the token was issued to.
157
     *
158
     * @param ClientEntityInterface $client
159
     */
160
    public function setClient(ClientEntityInterface $client)
161
    {
162
        $this->client = $client;
163
    }
164
165
    /**
166
     * @return string
167
     */
168
    public function getRedirectUri()
169
    {
170
        return $this->redirectUri;
171
    }
172
173
    /**
174
     * @param string $uri
175
     */
176
    public function setRedirectUri($uri)
177
    {
178
        $this->redirectUri = $uri;
179
    }
180
}