-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotification.php
More file actions
48 lines (40 loc) · 1.33 KB
/
Notification.php
File metadata and controls
48 lines (40 loc) · 1.33 KB
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
45
46
47
48
<?php
namespace Perform\NotificationBundle;
use Perform\NotificationBundle\Recipient\RecipientInterface;
/**
* Immutable notification object, sent with Notifier.
*/
class Notification
{
protected $recipients;
protected $type;
protected $context;
/**
* @param RecipientInterface[] $recipients An array of recipients
* @param string $type Notification type
* @param array $context Any variables required for the notification type
*/
public function __construct($recipients, $type, array $context = [])
{
$this->recipients = is_array($recipients) ? $recipients : [$recipients];
foreach ($this->recipients as $recipient) {
if (!$recipient instanceof RecipientInterface) {
throw new \InvalidArgumentException(sprintf('%s must be supplied an array of objects implementing %s, %s given.', __CLASS__, RecipientInterface::class, is_object($recipient) ? get_class($recipient) : var_export($recipient, true)));
}
}
$this->type = $type;
$this->context = $context;
}
public function getRecipients()
{
return $this->recipients;
}
public function getType()
{
return $this->type;
}
public function getContext()
{
return $this->context;
}
}