Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Hooks | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
onOAuthClaimStoreGetClaims | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\OAuthRateLimiter; |
4 | |
5 | use MediaWiki\Extension\OAuth\Entity\ClaimEntity; |
6 | use MediaWiki\Extension\OAuth\Entity\MWClientEntityInterface; |
7 | use MediaWiki\Extension\OAuth\Repository\Hook\OAuthClaimStoreGetClaimsHook; |
8 | |
9 | class Hooks implements OAuthClaimStoreGetClaimsHook { |
10 | |
11 | /** |
12 | * @var TierManager |
13 | */ |
14 | private $tierManager; |
15 | |
16 | /** |
17 | * @param TierManager $tierManager |
18 | */ |
19 | public function __construct( TierManager $tierManager ) { |
20 | $this->tierManager = $tierManager; |
21 | } |
22 | |
23 | /** |
24 | * @param string $grantType |
25 | * @param MWClientEntityInterface $clientEntity |
26 | * @param array &$privateClaims |
27 | * @param string|null $userIdentifier |
28 | */ |
29 | public function onOAuthClaimStoreGetClaims( |
30 | string $grantType, MWClientEntityInterface $clientEntity, array &$privateClaims, $userIdentifier = null |
31 | ) { |
32 | $clientID = $clientEntity->getIdentifier(); |
33 | $res = $this->tierManager->getClientTierConfig( $clientID ); |
34 | |
35 | foreach ( $res as $name => $value ) { |
36 | $privateClaims[] = new ClaimEntity( $name, $value ); |
37 | } |
38 | } |
39 | } |