Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
| SubscriptionItem | |
0.00% |
0 / 8 |
|
0.00% |
0 / 8 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUserIdentity | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getItemName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLinkTarget | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getCreatedTimestamp | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getNotificationTimestamp | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getState | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isMuted | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\DiscussionTools; |
| 4 | |
| 5 | use MediaWiki\Linker\LinkTarget; |
| 6 | use MediaWiki\User\UserIdentity; |
| 7 | |
| 8 | /** |
| 9 | * Representation of a subscription to a given topic. |
| 10 | */ |
| 11 | class SubscriptionItem { |
| 12 | /** |
| 13 | * @param UserIdentity $user |
| 14 | * @param string $itemName |
| 15 | * @param LinkTarget $linkTarget |
| 16 | * @param int $state One of SubscriptionStore::STATE_* constants |
| 17 | * @param string|null $createdTimestamp When the subscription was created |
| 18 | * @param string|null $notifiedTimestamp When the item subscribed to last tried to trigger |
| 19 | * a notification (even if muted). |
| 20 | */ |
| 21 | public function __construct( |
| 22 | private readonly UserIdentity $user, |
| 23 | private readonly string $itemName, |
| 24 | private readonly LinkTarget $linkTarget, |
| 25 | private readonly int $state, |
| 26 | private readonly ?string $createdTimestamp, |
| 27 | private readonly ?string $notifiedTimestamp |
| 28 | ) { |
| 29 | } |
| 30 | |
| 31 | public function getUserIdentity(): UserIdentity { |
| 32 | return $this->user; |
| 33 | } |
| 34 | |
| 35 | public function getItemName(): string { |
| 36 | return $this->itemName; |
| 37 | } |
| 38 | |
| 39 | public function getLinkTarget(): LinkTarget { |
| 40 | return $this->linkTarget; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Get the creation timestamp of this entry. |
| 45 | */ |
| 46 | public function getCreatedTimestamp(): ?string { |
| 47 | return $this->createdTimestamp; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Get the notification timestamp of this entry. |
| 52 | */ |
| 53 | public function getNotificationTimestamp(): ?string { |
| 54 | return $this->notifiedTimestamp; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Get the subscription status of this entry. |
| 59 | * |
| 60 | * @return int One of SubscriptionStore::STATE_* constants |
| 61 | */ |
| 62 | public function getState(): int { |
| 63 | return $this->state; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Check if the notification is muted |
| 68 | */ |
| 69 | public function isMuted(): bool { |
| 70 | return $this->state === SubscriptionStore::STATE_UNSUBSCRIBED; |
| 71 | } |
| 72 | } |