Debian Codegraph @

extensions/DiscussionTools/includes/SubscriptionItem.php

raw symbols SCIP
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 private UserIdentity $user;
13 private string $itemName;
14 private LinkTarget $linkTarget;
15 private int $state;
16 private ?string $createdTimestamp;
17 private ?string $notifiedTimestamp;
18
19 /**
20 * @param UserIdentity $user
21 * @param string $itemName
22 * @param LinkTarget $linkTarget
23 * @param int $state One of SubscriptionStore::STATE_* constants
24 * @param string|null $createdTimestamp When the subscription was created
25 * @param string|null $notifiedTimestamp When the item subscribed to last tried to trigger
26 * a notification (even if muted).
27 */
28 public function __construct(
29 UserIdentity $user,
30 string $itemName,
31 LinkTarget $linkTarget,
32 int $state,
33 ?string $createdTimestamp,
34 ?string $notifiedTimestamp
35 ) {
36 $this->user = $user;
37 $this->itemName = $itemName;
38 $this->linkTarget = $linkTarget;
39 $this->state = $state;
40 $this->createdTimestamp = $createdTimestamp;
41 $this->notifiedTimestamp = $notifiedTimestamp;
42 }
43
44 public function getUserIdentity(): UserIdentity {
45 return $this->user;
46 }
47
48 public function getItemName(): string {
49 return $this->itemName;
50 }
51
52 public function getLinkTarget(): LinkTarget {
53 return $this->linkTarget;
54 }
55
56 /**
57 * Get the creation timestamp of this entry.
58 */
59 public function getCreatedTimestamp(): ?string {
60 return $this->createdTimestamp;
61 }
62
63 /**
64 * Get the notification timestamp of this entry.
65 */
66 public function getNotificationTimestamp(): ?string {
67 return $this->notifiedTimestamp;
68 }
69
70 /**
71 * Get the subscription status of this entry.
72 *
73 * @return int One of SubscriptionStore::STATE_* constants
74 */
75 public function getState(): int {
76 return $this->state;
77 }
78
79 /**
80 * Check if the notification is muted
81 */
82 public function isMuted(): bool {
83 return $this->state === SubscriptionStore::STATE_UNSUBSCRIBED;
84 }
85 }