Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
66.67% |
2 / 3 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
StaticUserImpactLookup | |
66.67% |
2 / 3 |
|
66.67% |
2 / 3 |
3.33 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getUserImpact | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setUserImpact | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\UserImpact; |
4 | |
5 | use MediaWiki\User\UserIdentity; |
6 | use Wikimedia\Rdbms\IDBAccessObject; |
7 | |
8 | class StaticUserImpactLookup implements UserImpactLookup, UserImpactStore { |
9 | |
10 | use ExpensiveUserImpactFallbackTrait; |
11 | |
12 | /** @var UserImpact[] User ID => user impact */ |
13 | private $userImpacts; |
14 | |
15 | /** |
16 | * @param UserImpact[] $userImpacts User ID => user impact |
17 | */ |
18 | public function __construct( array $userImpacts ) { |
19 | $this->userImpacts = $userImpacts; |
20 | } |
21 | |
22 | /** @inheritDoc */ |
23 | public function getUserImpact( UserIdentity $user, int $flags = IDBAccessObject::READ_NORMAL ): ?UserImpact { |
24 | return $this->userImpacts[$user->getId()] ?? null; |
25 | } |
26 | |
27 | /** @inheritDoc */ |
28 | public function setUserImpact( UserImpact $userImpact ): void { |
29 | $this->userImpacts[$userImpact->getUser()->getId()] = $userImpact; |
30 | } |
31 | } |