Skip to content

Commit

Permalink
[EasyWebhook] Implement rewind on stack (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
natepage committed Mar 9, 2021
1 parent 5f9f69e commit ba0108a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/EasyWebhook/src/Interfaces/StackInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
interface StackInterface
{
public function next(): MiddlewareInterface;

public function rewind(): void;
}
5 changes: 5 additions & 0 deletions packages/EasyWebhook/src/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ public function next(): MiddlewareInterface

return $next;
}

public function rewind(): void
{
$this->index = 0;
}
}
3 changes: 3 additions & 0 deletions packages/EasyWebhook/src/WebhookClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function getStack(): StackInterface

public function sendWebhook(WebhookInterface $webhook): WebhookResultInterface
{
// Make sure stack is "fresh"
$this->stack->rewind();

return $this->stack
->next()
->process($webhook, $this->stack);
Expand Down

0 comments on commit ba0108a

Please sign in to comment.