Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
RefreshTokenEntity | |
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 refresh 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\RefreshTokenEntityInterface; |
33 | use League\OAuth2\Server\Entities\Traits\EntityTrait; |
34 | use League\OAuth2\Server\Entities\Traits\RefreshTokenTrait; |
35 | |
36 | /** |
37 | * OAuth2 refresh token entity implementation. |
38 | * |
39 | * @category VuFind |
40 | * @package OAuth2 |
41 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
42 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
43 | * @link https://vufind.org Main Site |
44 | */ |
45 | class RefreshTokenEntity implements RefreshTokenEntityInterface, \JsonSerializable |
46 | { |
47 | use RefreshTokenTrait; |
48 | use EntityTrait; |
49 | |
50 | /** |
51 | * Serialize to a JSON string |
52 | * |
53 | * @return string |
54 | */ |
55 | #[\ReturnTypeWillChange] |
56 | public function jsonSerialize() |
57 | { |
58 | $properties = [ |
59 | 'identifier', |
60 | 'expiryDateTime', |
61 | ]; |
62 | |
63 | $result = []; |
64 | foreach ($properties as $property) { |
65 | $result[$property] = $this->{$property}; |
66 | } |
67 | $accessToken = $this->getAccessToken(); |
68 | $result['accessToken'] = $accessToken ? $accessToken->getIdentifier() : null; |
69 | return $result; |
70 | } |
71 | } |