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