Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
13 / 13 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
GroupSynchronizationResponse | |
100.00% |
13 / 13 |
|
100.00% |
7 / 7 |
7 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
isDone | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getRemainingMessages | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getGroupId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
hasTimedOut | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
toJsonArray | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
newFromJsonArray | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare( strict_types = 1 ); |
4 | |
5 | namespace MediaWiki\Extension\Translate\Synchronization; |
6 | |
7 | use JsonSerializable; |
8 | use MediaWiki\Json\JsonDeserializable; |
9 | use MediaWiki\Json\JsonDeserializableTrait; |
10 | use MediaWiki\Json\JsonDeserializer; |
11 | |
12 | /** |
13 | * Class encapsulating the response returned by the GroupSynchronizationCache |
14 | * when requested for an update on a group synchronization status. |
15 | * @author Abijeet Patro |
16 | * @license GPL-2.0-or-later |
17 | * @since 2020.06 |
18 | */ |
19 | class GroupSynchronizationResponse implements JsonSerializable, JsonDeserializable { |
20 | use JsonDeserializableTrait; |
21 | |
22 | /** @var MessageUpdateParameter[] */ |
23 | private array $remainingMessages; |
24 | private string $groupId; |
25 | private bool $timeout; |
26 | |
27 | public function __construct( |
28 | string $groupId, array $remainingMessages, bool $hasTimedOut |
29 | ) { |
30 | $this->groupId = $groupId; |
31 | $this->remainingMessages = $remainingMessages; |
32 | $this->timeout = $hasTimedOut; |
33 | } |
34 | |
35 | public function isDone(): bool { |
36 | return $this->remainingMessages === []; |
37 | } |
38 | |
39 | /** @return MessageUpdateParameter[] */ |
40 | public function getRemainingMessages(): array { |
41 | return $this->remainingMessages; |
42 | } |
43 | |
44 | public function getGroupId(): string { |
45 | return $this->groupId; |
46 | } |
47 | |
48 | public function hasTimedOut(): bool { |
49 | return $this->timeout; |
50 | } |
51 | |
52 | /** @return mixed[] */ |
53 | protected function toJsonArray(): array { |
54 | return get_object_vars( $this ); |
55 | } |
56 | |
57 | public static function newFromJsonArray( JsonDeserializer $deserializer, array $params ) { |
58 | return new self( |
59 | $params['groupId'], |
60 | $params['remainingMessages'], |
61 | $params['timeout'] |
62 | ); |
63 | } |
64 | } |