These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace AdvancedLearning\Oauth2Server\Repositories; |
||
4 | |||
5 | use AdvancedLearning\Oauth2Server\Entities\AccessTokenEntity as AccessTokenEntity; |
||
6 | use AdvancedLearning\Oauth2Server\Models\AccessToken; |
||
7 | use League\OAuth2\Server\Entities\AccessTokenEntityInterface; |
||
8 | use League\OAuth2\Server\Entities\ClientEntityInterface; |
||
9 | use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface; |
||
10 | |||
11 | class AccessTokenRepository implements AccessTokenRepositoryInterface |
||
12 | { |
||
13 | /** |
||
14 | * {@inheritdoc} |
||
15 | */ |
||
16 | public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity) |
||
17 | { |
||
18 | $newToken = AccessToken::create(); |
||
19 | |||
20 | $newToken->Identifier = $accessTokenEntity->getIdentifier(); |
||
21 | $newToken->Name = $accessTokenEntity->getClient()->getName(); |
||
22 | $newToken->User = $accessTokenEntity->getUserIdentifier(); |
||
0 ignored issues
–
show
|
|||
23 | $newToken->ExpiryDateTime = $accessTokenEntity->getExpiryDateTime()->format('Y-m-d H:i'); |
||
24 | |||
25 | // turn scopes into space separated string |
||
26 | $newToken->Scopes = ''; |
||
27 | $separator = ''; |
||
28 | foreach ($accessTokenEntity->getScopes() as $scope) { |
||
29 | $newToken->Scopes .= $separator . $scope->getIdentifier(); |
||
30 | $separator = ' '; |
||
31 | } |
||
32 | |||
33 | $newToken->write(); |
||
34 | |||
35 | return $newToken; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null) |
||
42 | { |
||
43 | return new AccessTokenEntity($userIdentifier, $scopes); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | public function revokeAccessToken($tokenId) |
||
50 | { |
||
51 | if ($token = $this->findToken($tokenId)) { |
||
52 | $token->Revoked = true; |
||
53 | $token->write(); |
||
54 | } |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function isAccessTokenRevoked($tokenId): bool |
||
61 | { |
||
62 | $token = $this->findToken($tokenId); |
||
63 | |||
64 | // return true if there is no matching token |
||
65 | return empty($token) || $token->Revoked; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Find the Token for passed id. |
||
70 | * |
||
71 | * @param string $tokenId The id of the token. |
||
72 | * |
||
73 | * @return AccessToken|null |
||
74 | */ |
||
75 | public function findToken(string $tokenId): ?AccessToken |
||
76 | { |
||
77 | return AccessToken::get()->filter(['Identifier' => $tokenId])->first(); |
||
78 | } |
||
79 | } |
||
80 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.