Code Duplication    Length = 155-165 lines in 2 locations

src/Entity/OAuth/AccessToken.php 1 location

@@ 17-171 (lines=155) @@
14
* @ORM\Entity(repositoryClass="OAuth\Repository\AccessTokenRepository")
15
* @ORM\Table(name="AccessToken")
16
*/
17
class AccessToken implements AccessTokenEntityInterface
18
{
19
    use AccessTokenTrait;
20
21
    /**
22
     * @var ArrayCollection $scopes
23
     * @ORM\ManyToMany(targetEntity="Scope", inversedBy="accessTokens")
24
     * @ORM\JoinTable(name="AccessToken_Scope",
25
     *      joinColumns={@ORM\JoinColumn(name="token_id", referencedColumnName="identifier")},
26
     *      inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="identifier")}
27
     *      )
28
     */
29
    protected $scopes;
30
31
    /**
32
     * @var DateTime
33
     * @ORM\Column(type="date",nullable=true)
34
     */
35
    protected $expiryDateTime;
36
37
    /**
38
     * @var int
39
     * @ORM\Column(type="integer", length=11)
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\Id
53
     * @ORM\Column(type="string", length=40)
54
     */
55
    protected $identifier;
56
57
    public function __construct()
58
    {
59
        $this->scopes = new ArrayCollection();
60
    }
61
62
    /**
63
     * Set token
64
     *
65
     * @param string $token
66
     * @return AccessToken
67
     */
68
    public function setToken($token)
69
    {
70
        $this->token = $token;
71
        return $this;
72
    }
73
74
    /**
75
     * Get token
76
     *
77
     * @return string
78
     */
79
    public function getIdentifier()
80
    {
81
        return $this->identifier;
82
    }
83
84
    /**
85
     * @param string $identifier
86
     */
87
    public function setIdentifier($identifier)
88
    {
89
        $this->identifier = $identifier;
90
    }
91
92
    /**
93
     * @param ScopeEntityInterface $scope
94
     * @return $this
95
     */
96
    public function addScope(ScopeEntityInterface $scope)
97
    {
98
        $this->scopes->add($scope);
99
        return $this;
100
    }
101
102
    /**
103
     * Return an array of scopes associated with the token.
104
     *
105
     * @return ScopeEntityInterface[]
106
     */
107
    public function getScopes()
108
    {
109
        return $this->scopes->toArray();
110
    }
111
112
    /**
113
     * Get the token's expiry date time.
114
     *
115
     * @return DateTime
116
     */
117
    public function getExpiryDateTime()
118
    {
119
        return $this->expiryDateTime;
120
    }
121
122
    /**
123
     * Set the date time when the token expires.
124
     *
125
     * @param DateTime $dateTime
126
     */
127
    public function setExpiryDateTime(DateTime $dateTime)
128
    {
129
        $this->expiryDateTime = $dateTime;
130
    }
131
132
    /**
133
     * @param int $identifier
134
     * @return $this
135
     */
136
    public function setUserIdentifier($identifier)
137
    {
138
        $this->userIdentifier = $identifier;
139
        return $this;
140
    }
141
142
    /**
143
     * Get the token user's identifier.
144
     *
145
     * @return int
146
     */
147
    public function getUserIdentifier()
148
    {
149
        return $this->userIdentifier;
150
    }
151
152
    /**
153
     * Get the client that the token was issued to.
154
     *
155
     * @return ClientEntityInterface
156
     */
157
    public function getClient()
158
    {
159
        return $this->client;
160
    }
161
162
    /**
163
     * Set the client that the token was issued to.
164
     *
165
     * @param ClientEntityInterface $client
166
     */
167
    public function setClient(ClientEntityInterface $client)
168
    {
169
        $this->client = $client;
170
    }
171
}

src/Entity/OAuth/AuthCode.php 1 location

@@ 16-180 (lines=165) @@
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
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;
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
}