Skip to content

Commit 425d5e0

Browse files
committed
Add setTopicArn methods to SnsContext and SnsQsContext
1 parent 3880257 commit 425d5e0

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

Diff for: pkg/sns/SnsContext.php

+5
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ public function declareTopic(SnsDestination $destination): void
7676
$this->topicArns[$destination->getTopicName()] = (string) $result->get('TopicArn');
7777
}
7878

79+
public function setTopicArn(SnsDestination $destination, string $arn): void
80+
{
81+
$this->topicArns[$destination->getTopicName()] = $arn;
82+
}
83+
7984
public function deleteTopic(SnsDestination $destination): void
8085
{
8186
$this->client->deleteTopic($this->getTopicArn($destination));

Diff for: pkg/snsqs/SnsQsContext.php

+9-20
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,15 @@ public function __construct($snsContext, $sqsContext)
5353
} elseif (is_callable($snsContext)) {
5454
$this->snsContextFactory = $snsContext;
5555
} else {
56-
throw new \InvalidArgumentException(sprintf(
57-
'The $snsContext argument must be either %s or callable that returns %s once called.',
58-
SnsContext::class,
59-
SnsContext::class
60-
));
56+
throw new \InvalidArgumentException(sprintf('The $snsContext argument must be either %s or callable that returns %s once called.', SnsContext::class, SnsContext::class));
6157
}
6258

6359
if ($sqsContext instanceof SqsContext) {
6460
$this->sqsContext = $sqsContext;
6561
} elseif (is_callable($sqsContext)) {
6662
$this->sqsContextFactory = $sqsContext;
6763
} else {
68-
throw new \InvalidArgumentException(sprintf(
69-
'The $sqsContext argument must be either %s or callable that returns %s once called.',
70-
SqsContext::class,
71-
SqsContext::class
72-
));
64+
throw new \InvalidArgumentException(sprintf('The $sqsContext argument must be either %s or callable that returns %s once called.', SqsContext::class, SqsContext::class));
7365
}
7466
}
7567

@@ -137,6 +129,11 @@ public function declareTopic(SnsQsTopic $topic): void
137129
$this->getSnsContext()->declareTopic($topic);
138130
}
139131

132+
public function setTopicArn(SnsQsTopic $topic, string $arn): void
133+
{
134+
$this->getSnsContext()->setTopicArn($topic);
135+
}
136+
140137
public function deleteTopic(SnsQsTopic $topic): void
141138
{
142139
$this->getSnsContext()->deleteTopic($topic);
@@ -181,11 +178,7 @@ private function getSnsContext(): SnsContext
181178
if (null === $this->snsContext) {
182179
$context = call_user_func($this->snsContextFactory);
183180
if (false == $context instanceof SnsContext) {
184-
throw new \LogicException(sprintf(
185-
'The factory must return instance of %s. It returned %s',
186-
SnsContext::class,
187-
is_object($context) ? get_class($context) : gettype($context)
188-
));
181+
throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', SnsContext::class, is_object($context) ? get_class($context) : gettype($context)));
189182
}
190183

191184
$this->snsContext = $context;
@@ -199,11 +192,7 @@ private function getSqsContext(): SqsContext
199192
if (null === $this->sqsContext) {
200193
$context = call_user_func($this->sqsContextFactory);
201194
if (false == $context instanceof SqsContext) {
202-
throw new \LogicException(sprintf(
203-
'The factory must return instance of %s. It returned %s',
204-
SqsContext::class,
205-
is_object($context) ? get_class($context) : gettype($context)
206-
));
195+
throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', SqsContext::class, is_object($context) ? get_class($context) : gettype($context)));
207196
}
208197

209198
$this->sqsContext = $context;

0 commit comments

Comments
 (0)