SubscriptionMode.php
1 year ago
SubscriptionPeriod.php
3 years ago
SubscriptionStatus.php
11 months ago
SubscriptionStatus.php
84 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Subscriptions\ValueObjects; |
| 4 | |
| 5 | use Give\Framework\Support\ValueObjects\Enum; |
| 6 | |
| 7 | /** |
| 8 | * @since 3.17.0 Added a new "paused" status |
| 9 | * @since 2.19.6 |
| 10 | * |
| 11 | * @method static SubscriptionStatus PENDING() |
| 12 | * @method static SubscriptionStatus ACTIVE() |
| 13 | * @method static SubscriptionStatus EXPIRED() |
| 14 | * @method static SubscriptionStatus COMPLETED() |
| 15 | * @method static SubscriptionStatus REFUNDED() @deprecated Do not use this. Use SubscriptionStatus::CANCELLED() or SubscriptionStatus::SUSPENDED() instead. |
| 16 | * @method static SubscriptionStatus ABANDONED() @deprecated Do not use this. Use SubscriptionStatus::CANCELLED() instead. |
| 17 | * @method static SubscriptionStatus FAILING() |
| 18 | * @method static SubscriptionStatus CANCELLED() |
| 19 | * @method static SubscriptionStatus SUSPENDED() |
| 20 | * @method static SubscriptionStatus PAUSED() |
| 21 | * @method bool isPending() |
| 22 | * @method bool isActive() |
| 23 | * @method bool isExpired() |
| 24 | * @method bool isCompleted() |
| 25 | * @method bool isRefunded() @deprecated Do not use this. Instead, use the CANCELLED or SUSPENDED statuses. |
| 26 | * @method bool isAbandoned() @deprecated Do not use this. Instead, use the CANCELLED status. |
| 27 | * @method bool isFailing() |
| 28 | * @method bool isCancelled() |
| 29 | * @method bool isSuspended() |
| 30 | * @method bool isPaused() |
| 31 | */ |
| 32 | class SubscriptionStatus extends Enum { |
| 33 | const PENDING = 'pending'; |
| 34 | const ACTIVE = 'active'; |
| 35 | const EXPIRED = 'expired'; |
| 36 | const COMPLETED = 'completed'; |
| 37 | const FAILING = 'failing'; |
| 38 | const CANCELLED = 'cancelled'; |
| 39 | const SUSPENDED = 'suspended'; |
| 40 | const PAUSED = 'paused'; |
| 41 | |
| 42 | /** |
| 43 | * @deprecated Do not use this. Use SubscriptionStatus::CANCELLED or SubscriptionStatus::SUSPENDED instead. |
| 44 | */ |
| 45 | const REFUNDED = 'refunded'; |
| 46 | |
| 47 | /** |
| 48 | * @deprecated Do not use this. Use SubscriptionStatus::CANCELLED instead. |
| 49 | */ |
| 50 | const ABANDONED = 'abandoned'; |
| 51 | |
| 52 | /** |
| 53 | * @since 3.17.0 Added a new "paused" status |
| 54 | * @since 2.24.0 |
| 55 | * |
| 56 | * @return array |
| 57 | */ |
| 58 | public static function labels(): array |
| 59 | { |
| 60 | return [ |
| 61 | self::PENDING => __( 'Pending', 'give' ), |
| 62 | self::ACTIVE => __( 'Active', 'give' ), |
| 63 | self::EXPIRED => __( 'Expired', 'give' ), |
| 64 | self::COMPLETED => __( 'Completed', 'give' ), |
| 65 | self::REFUNDED => __( 'Refunded', 'give' ), |
| 66 | self::FAILING => __( 'Failed', 'give' ), |
| 67 | self::CANCELLED => __( 'Cancelled', 'give' ), |
| 68 | self::ABANDONED => __( 'Abandoned', 'give' ), |
| 69 | self::SUSPENDED => __( 'Suspended', 'give' ), |
| 70 | self::PAUSED => __('Paused', 'give'), |
| 71 | ]; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * @since 2.24.0 |
| 76 | * |
| 77 | * @return string |
| 78 | */ |
| 79 | public function label(): string |
| 80 | { |
| 81 | return self::labels()[ $this->getValue() ]; |
| 82 | } |
| 83 | } |
| 84 |