Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 8
CRAP
0.00% covered (danger)
0.00%
0 / 1
SubscriptionItem
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 8
72
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 getUserIdentity
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getItemName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLinkTarget
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getCreatedTimestamp
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNotificationTimestamp
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getState
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isMuted
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Extension\DiscussionTools;
4
5use MediaWiki\Linker\LinkTarget;
6use MediaWiki\User\UserIdentity;
7
8/**
9 * Representation of a subscription to a given topic.
10 */
11class 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    /**
45     * @return UserIdentity
46     */
47    public function getUserIdentity(): UserIdentity {
48        return $this->user;
49    }
50
51    /**
52     * @return string
53     */
54    public function getItemName(): string {
55        return $this->itemName;
56    }
57
58    /**
59     * @return LinkTarget
60     */
61    public function getLinkTarget(): LinkTarget {
62        return $this->linkTarget;
63    }
64
65    /**
66     * Get the creation timestamp of this entry.
67     *
68     * @return string|null
69     */
70    public function getCreatedTimestamp(): ?string {
71        return $this->createdTimestamp;
72    }
73
74    /**
75     * Get the notification timestamp of this entry.
76     *
77     * @return string|null
78     */
79    public function getNotificationTimestamp(): ?string {
80        return $this->notifiedTimestamp;
81    }
82
83    /**
84     * Get the subscription status of this entry.
85     *
86     * @return int One of SubscriptionStore::STATE_* constants
87     */
88    public function getState(): int {
89        return $this->state;
90    }
91
92    /**
93     * Check if the notification is muted
94     *
95     * @return bool
96     */
97    public function isMuted(): bool {
98        return $this->state === SubscriptionStore::STATE_UNSUBSCRIBED;
99    }
100}