Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| TemporaryAccountIPsViewerSpecification | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isSatisfiedBy | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\AbuseFilter; |
| 4 | |
| 5 | use MediaWiki\CheckUser\Services\CheckUserPermissionManager; |
| 6 | use MediaWiki\Permissions\Authority; |
| 7 | use MediaWiki\User\TempUser\TempUserConfig; |
| 8 | |
| 9 | class TemporaryAccountIPsViewerSpecification { |
| 10 | |
| 11 | public const SERVICE_NAME = 'TemporaryAccountIPsViewerSpecification'; |
| 12 | |
| 13 | public function __construct( |
| 14 | private readonly TempUserConfig $tempUserConfig, |
| 15 | private readonly ?CheckUserPermissionManager $checkUserPermissionManager, |
| 16 | ) { |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Checks if the given Authority is allowed to see IPs associated with |
| 21 | * temporary accounts. |
| 22 | * |
| 23 | * @param Authority $performer Authority to check permissions for. |
| 24 | * @return bool Whether the Authority can see Temp Account IPs. |
| 25 | */ |
| 26 | public function isSatisfiedBy( Authority $performer ): bool { |
| 27 | return $this->tempUserConfig->isKnown() && |
| 28 | $this->checkUserPermissionManager !== null && |
| 29 | $this->checkUserPermissionManager |
| 30 | ->canAccessTemporaryAccountIPAddresses( $performer ) |
| 31 | ->isGood(); |
| 32 | } |
| 33 | } |