Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
13 / 13 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
ScopeEntity | |
100.00% |
13 / 13 |
|
100.00% |
7 / 7 |
9 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 | |||
getDescription | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setDescription | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getHidden | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setHidden | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getILSNeeded | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setILSNeeded | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * OAuth2 scope 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\ScopeEntityInterface; |
33 | use League\OAuth2\Server\Entities\Traits\EntityTrait; |
34 | use League\OAuth2\Server\Entities\Traits\ScopeTrait; |
35 | |
36 | /** |
37 | * OAuth2 scope 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 ScopeEntity implements ScopeEntityInterface |
46 | { |
47 | use EntityTrait; |
48 | use ScopeTrait; |
49 | |
50 | /** |
51 | * Scope description |
52 | * |
53 | * @var string |
54 | */ |
55 | protected $description; |
56 | |
57 | /** |
58 | * Whether the scope is hidden from the scope list |
59 | * |
60 | * @var bool |
61 | */ |
62 | protected $hidden; |
63 | |
64 | /** |
65 | * Whether the scope requires data from an ILS account |
66 | * |
67 | * @var bool |
68 | */ |
69 | protected $ilsNeeded; |
70 | |
71 | /** |
72 | * Constructor |
73 | * |
74 | * @param array $config Scope configuration |
75 | */ |
76 | public function __construct(array $config) |
77 | { |
78 | foreach (['identifier', 'description'] as $required) { |
79 | if (!isset($config[$required])) { |
80 | throw new \Exception("OAuth2 scope config missing '$required'"); |
81 | } |
82 | } |
83 | $this->setIdentifier($config['identifier']); |
84 | $this->setDescription($config['description']); |
85 | $this->setILSNeeded((bool)($config['ils'] ?? false)); |
86 | $this->setHidden($config['hidden'] ?? false); |
87 | } |
88 | |
89 | /** |
90 | * Get description |
91 | * |
92 | * @return string |
93 | */ |
94 | public function getDescription(): string |
95 | { |
96 | return $this->description; |
97 | } |
98 | |
99 | /** |
100 | * Set description |
101 | * |
102 | * @param string $description Description |
103 | * |
104 | * @return void |
105 | */ |
106 | public function setDescription(string $description): void |
107 | { |
108 | $this->description = $description; |
109 | } |
110 | |
111 | /** |
112 | * Get hidden flag |
113 | * |
114 | * @return bool |
115 | */ |
116 | public function getHidden(): bool |
117 | { |
118 | return $this->hidden; |
119 | } |
120 | |
121 | /** |
122 | * Set hidden flag |
123 | * |
124 | * @param bool $value New value |
125 | * |
126 | * @return void |
127 | */ |
128 | public function setHidden(bool $value): void |
129 | { |
130 | $this->hidden = $value; |
131 | } |
132 | |
133 | /** |
134 | * Get ILS needed flag |
135 | * |
136 | * @return bool |
137 | */ |
138 | public function getILSNeeded(): bool |
139 | { |
140 | return $this->ilsNeeded; |
141 | } |
142 | |
143 | /** |
144 | * Set ILS needed flag |
145 | * |
146 | * @param bool $value New value |
147 | * |
148 | * @return void |
149 | */ |
150 | public function setILSNeeded(bool $value): void |
151 | { |
152 | $this->ilsNeeded = $value; |
153 | } |
154 | } |