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