Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
AccessTokenEntity | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
jsonSerialize | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | |
3 | /** |
4 | * OAuth2 access token entity implementation. |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) The National Library of Finland 2022. |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2, |
12 | * as published by the Free Software Foundation. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. |
18 | * |
19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 | * |
23 | * @category VuFind |
24 | * @package OAuth2 |
25 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
26 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org Main Site |
28 | */ |
29 | |
30 | namespace VuFind\OAuth2\Entity; |
31 | |
32 | use League\OAuth2\Server\Entities\AccessTokenEntityInterface; |
33 | use League\OAuth2\Server\Entities\Traits\AccessTokenTrait; |
34 | use League\OAuth2\Server\Entities\Traits\EntityTrait; |
35 | use League\OAuth2\Server\Entities\Traits\TokenEntityTrait; |
36 | |
37 | /** |
38 | * OAuth2 access token entity implementation. |
39 | * |
40 | * @category VuFind |
41 | * @package OAuth2 |
42 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
43 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
44 | * @link https://vufind.org Main Site |
45 | */ |
46 | class AccessTokenEntity implements AccessTokenEntityInterface, \JsonSerializable |
47 | { |
48 | use AccessTokenTrait; |
49 | use TokenEntityTrait; |
50 | use EntityTrait; |
51 | |
52 | /** |
53 | * Serialize to a JSON string |
54 | * |
55 | * @return string |
56 | */ |
57 | #[\ReturnTypeWillChange] |
58 | public function jsonSerialize() |
59 | { |
60 | $properties = [ |
61 | 'identifier', |
62 | 'expiryDateTime', |
63 | 'userIdentifier', |
64 | ]; |
65 | |
66 | $result = []; |
67 | foreach ($properties as $property) { |
68 | $result[$property] = $this->{$property}; |
69 | } |
70 | $client = $this->getClient(); |
71 | $result['clientIdentifier'] = $client ? $client->getIdentifier() : null; |
72 | |
73 | return $result; |
74 | } |
75 | } |