aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Notification/NotificationEnvelope.php
blob: 718e73fdced2c61e53662e30f0e0e635fca70774 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace MediaWiki\Notification;

/**
 * An object representing notification with list of recipients
 * @since 1.44
 * @unstable
 */
class NotificationEnvelope {

	private Notification $notification;
	private RecipientSet $recipientSet;

	public function __construct( Notification $notification, RecipientSet $recipientSet ) {
		$this->notification = $notification;
		$this->recipientSet = $recipientSet;
	}

	public function getNotification(): Notification {
		return $this->notification;
	}

	public function getRecipientSet(): RecipientSet {
		return $this->recipientSet;
	}

	/**
	 * Syntax sugar, allows easy check if two envelopes point to the same thing
	 */
	public function equals( NotificationEnvelope $envelope ): bool {
		return $envelope === $this;
	}

	/**
	 * Check if the Notification has defined agent.
	 *
	 * Utility method for a very common check where middleware filters Notifications from
	 * specific agent.
	 */
	public function hasAgent(): bool {
		return $this->notification instanceof AgentAware;
	}

}