forked from php-enqueue/sns
/
SnsDestination.php
91 lines (73 loc) · 2 KB
/
SnsDestination.php
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
declare(strict_types=1);
namespace Enqueue\Sns;
use Interop\Queue\Queue;
use Interop\Queue\Topic;
class SnsDestination implements Topic, Queue
{
private $name;
private $topicArn;
private $attributes;
public function __construct(string $name)
{
$this->name = $name;
$this->attributes = [];
}
public function getQueueName(): string
{
return $this->name;
}
public function getTopicName(): string
{
return $this->name;
}
/**
* The policy that defines who can access your topic. By default, only the topic owner can publish or subscribe to the topic.
*/
public function setPolicy(string $policy = null): void
{
$this->setAttribute('Policy', $policy);
}
public function getPolicy(): ?string
{
return $this->getAttribute('Policy');
}
/**
* The display name to use for a topic with SMS subscriptions.
*/
public function setDisplayName(string $displayName = null): void
{
$this->setAttribute('DisplayName', $displayName);
}
public function getDisplayName(): ?string
{
return $this->getAttribute('DisplayName');
}
/**
* The display name to use for a topic with SMS subscriptions.
*/
public function setDeliveryPolicy(int $deliveryPolicy = null): void
{
$this->setAttribute('DeliveryPolicy', $deliveryPolicy);
}
public function getDeliveryPolicy(): ?int
{
return $this->getAttribute('DeliveryPolicy');
}
public function getAttributes(): array
{
return $this->attributes;
}
private function getAttribute(string $name, $default = null)
{
return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
}
private function setAttribute(string $name, $value): void
{
if (null == $value) {
unset($this->attributes[$name]);
} else {
$this->attributes[$name] = $value;
}
}
}