Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
50.00% |
2 / 4 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
LoggedInRequirement | |
50.00% |
2 / 4 |
|
66.67% |
2 / 3 |
4.12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isMet | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the License, or |
7 | * (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License along |
15 | * with this program; if not, write to the Free Software Foundation, Inc., |
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | * http://www.gnu.org/copyleft/gpl.html |
18 | * |
19 | * @file |
20 | * @since 1.35 |
21 | */ |
22 | |
23 | namespace MediaWiki\Skins\Vector\FeatureManagement\Requirements; |
24 | |
25 | use MediaWiki\Skins\Vector\FeatureManagement\Requirement; |
26 | use MediaWiki\User\UserIdentity; |
27 | |
28 | /** |
29 | * @package MediaWiki\Skins\Vector\FeatureManagement\Requirements |
30 | * @internal |
31 | */ |
32 | class LoggedInRequirement implements Requirement { |
33 | |
34 | private UserIdentity $user; |
35 | |
36 | /** |
37 | * The name of the requirement |
38 | */ |
39 | private string $name; |
40 | |
41 | /** |
42 | * @param UserIdentity $user |
43 | * @param string $name The name of the requirement |
44 | */ |
45 | public function __construct( UserIdentity $user, string $name ) { |
46 | $this->user = $user; |
47 | $this->name = $name; |
48 | } |
49 | |
50 | /** |
51 | * @inheritDoc |
52 | */ |
53 | public function getName(): string { |
54 | return $this->name; |
55 | } |
56 | |
57 | /** |
58 | * Returns true if the user is logged-in and false otherwise. |
59 | * |
60 | * @inheritDoc |
61 | */ |
62 | public function isMet(): bool { |
63 | return $this->user->isRegistered(); |
64 | } |
65 | } |