| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Deferred; |
| 4 |
|
| 5 |
use InvalidArgumentException; |
| 6 |
use MediaWiki\User\UserIdentity; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
class UserEditCountInfo { |
| 13 |
|
| 14 |
private $user; |
| 15 |
|
| 16 |
|
| 17 |
private $increment; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
public function __construct( UserIdentity $user, int $increment ) { |
| 25 |
$this->user = $user; |
| 26 |
$this->increment = $increment; |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 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 |
|
| 43 |
|
| 44 |
public function getUser() { |
| 45 |
return $this->user; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public function getIncrement() { |
| 52 |
return $this->increment; |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
class_alias( UserEditCountInfo::class, 'UserEditCountInfo' ); |