Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
87.50% |
7 / 8 |
|
80.00% |
4 / 5 |
CRAP | |
0.00% |
0 / 1 |
AccessToken | |
87.50% |
7 / 8 |
|
80.00% |
4 / 5 |
5.05 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setUser | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
setData | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
isRevoked | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setRevoked | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * Row Definition for access_token |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2010. |
9 | * Copyright (C) The National Library of Finland 2022-2024. |
10 | * |
11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License version 2, |
13 | * as published by the Free Software Foundation. |
14 | * |
15 | * This program is distributed in the hope that it will be useful, |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | * GNU General Public License for more details. |
19 | * |
20 | * You should have received a copy of the GNU General Public License |
21 | * along with this program; if not, write to the Free Software |
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
23 | * |
24 | * @category VuFind |
25 | * @package Db_Row |
26 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
27 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
28 | * @link https://vufind.org Main Site |
29 | */ |
30 | |
31 | namespace VuFind\Db\Row; |
32 | |
33 | use VuFind\Db\Entity\AccessTokenEntityInterface; |
34 | use VuFind\Db\Entity\UserEntityInterface; |
35 | |
36 | /** |
37 | * Row Definition for access_token |
38 | * |
39 | * @category VuFind |
40 | * @package Db_Row |
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 AccessToken extends RowGateway implements AccessTokenEntityInterface |
46 | { |
47 | /** |
48 | * Constructor |
49 | * |
50 | * @param \Laminas\Db\Adapter\Adapter $adapter Database adapter |
51 | */ |
52 | public function __construct($adapter) |
53 | { |
54 | parent::__construct(['id', 'type'], 'access_token', $adapter); |
55 | } |
56 | |
57 | /** |
58 | * Set user ID. |
59 | * |
60 | * @param ?UserEntityInterface $user User owning token |
61 | * |
62 | * @return AccessTokenEntityInterface |
63 | */ |
64 | public function setUser(?UserEntityInterface $user): AccessTokenEntityInterface |
65 | { |
66 | $this->__set('user_id', $user?->getId()); |
67 | return $this; |
68 | } |
69 | |
70 | /** |
71 | * Set data. |
72 | * |
73 | * @param string $data Data |
74 | * |
75 | * @return AccessTokenEntityInterface |
76 | */ |
77 | public function setData(string $data): AccessTokenEntityInterface |
78 | { |
79 | $this->__set('data', $data); |
80 | return $this; |
81 | } |
82 | |
83 | /** |
84 | * Is the access token revoked? |
85 | * |
86 | * @return bool |
87 | */ |
88 | public function isRevoked(): bool |
89 | { |
90 | return $this->__get('revoked'); |
91 | } |
92 | |
93 | /** |
94 | * Set revoked status. |
95 | * |
96 | * @param bool $revoked Revoked |
97 | * |
98 | * @return AccessTokenEntityInterface |
99 | */ |
100 | public function setRevoked(bool $revoked): AccessTokenEntityInterface |
101 | { |
102 | $this->__set('revoked', $revoked); |
103 | return $this; |
104 | } |
105 | } |