Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
UserEditCountInfo | |
0.00% |
0 / 7 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
merge | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getIncrement | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Deferred; |
4 | |
5 | use InvalidArgumentException; |
6 | use MediaWiki\User\UserIdentity; |
7 | |
8 | /** |
9 | * Helper class for UserEditCountUpdate |
10 | * @since 1.38 |
11 | */ |
12 | class UserEditCountInfo { |
13 | /** @var UserIdentity */ |
14 | private $user; |
15 | |
16 | /** @var int */ |
17 | private $increment; |
18 | |
19 | /** |
20 | * @internal |
21 | * @param UserIdentity $user |
22 | * @param int $increment |
23 | */ |
24 | public function __construct( UserIdentity $user, int $increment ) { |
25 | $this->user = $user; |
26 | $this->increment = $increment; |
27 | } |
28 | |
29 | /** |
30 | * Merge another UserEditCountInfo into this one |
31 | * |
32 | * @param UserEditCountInfo $other |
33 | */ |
34 | public function merge( self $other ) { |
35 | if ( !$this->user->equals( $other->user ) ) { |
36 | throw new InvalidArgumentException( __METHOD__ . ': user does not match' ); |
37 | } |
38 | $this->increment += $other->increment; |
39 | } |
40 | |
41 | /** |
42 | * @return UserIdentity |
43 | */ |
44 | public function getUser() { |
45 | return $this->user; |
46 | } |
47 | |
48 | /** |
49 | * @return int |
50 | */ |
51 | public function getIncrement() { |
52 | return $this->increment; |
53 | } |
54 | } |
55 | |
56 | /** @deprecated class alias since 1.42 */ |
57 | class_alias( UserEditCountInfo::class, 'UserEditCountInfo' ); |