give
/
src
/
Framework
/
PaymentGateways
/
Webhooks
/
EventHandlers
/
Actions
/
GetEventHandlerClassBySubscriptionStatus.php
GetEventHandlerClassByDonationStatus.php
11 months ago
GetEventHandlerClassBySubscriptionStatus.php
11 months ago
UpdateDonationStatus.php
2 years ago
UpdateSubscriptionStatus.php
11 months ago
GetEventHandlerClassBySubscriptionStatus.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Framework\PaymentGateways\Webhooks\EventHandlers\Actions; |
| 4 | |
| 5 | use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionActive; |
| 6 | use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionCancelled; |
| 7 | use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionCompleted; |
| 8 | use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionExpired; |
| 9 | use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionFailing; |
| 10 | use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionPaused; |
| 11 | use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionPending; |
| 12 | use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionSuspended; |
| 13 | use Give\Subscriptions\ValueObjects\SubscriptionStatus; |
| 14 | |
| 15 | /** |
| 16 | * @since 4.5.0 |
| 17 | */ |
| 18 | class GetEventHandlerClassBySubscriptionStatus |
| 19 | { |
| 20 | /** |
| 21 | * @since 4.5.0 |
| 22 | */ |
| 23 | public function __invoke(SubscriptionStatus $status): string |
| 24 | { |
| 25 | switch ($status) { |
| 26 | case $status->isActive(): |
| 27 | return SubscriptionActive::class; |
| 28 | case $status->isCancelled(): |
| 29 | return SubscriptionCancelled::class; |
| 30 | case $status->isCompleted(): |
| 31 | return SubscriptionCompleted::class; |
| 32 | case $status->isExpired(): |
| 33 | return SubscriptionExpired::class; |
| 34 | case $status->isFailing(): |
| 35 | return SubscriptionFailing::class; |
| 36 | case $status->isPaused(): |
| 37 | return SubscriptionPaused::class; |
| 38 | case $status->isPending(): |
| 39 | return SubscriptionPending::class; |
| 40 | case $status->isSuspended(): |
| 41 | return SubscriptionSuspended::class; |
| 42 | default: |
| 43 | return ''; |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 |