Admin
11 months ago
Helpers
1 year ago
Migrations
4 years ago
MigrationLogFactory.php
4 years ago
MigrationLogModel.php
4 years ago
MigrationLogRepository.php
1 year ago
MigrationLogServiceProvider.php
4 years ago
MigrationLogStatus.php
1 year ago
MigrationLogStatus.php
53 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\MigrationLog; |
| 4 | |
| 5 | /** |
| 6 | * Class MigrationLogStatus |
| 7 | * @package Give\MigrationLog |
| 8 | * |
| 9 | * @since 4.3.0 add REVERSED status |
| 10 | * @since 4.0.0 add RUNNING and INCOMPLETE statuses |
| 11 | * @since 2.10.0 |
| 12 | */ |
| 13 | class MigrationLogStatus |
| 14 | { |
| 15 | const SUCCESS = 'success'; |
| 16 | const FAILED = 'failed'; |
| 17 | const PENDING = 'pending'; |
| 18 | const RUNNING = 'running'; |
| 19 | const INCOMPLETE = 'incomplete'; |
| 20 | const REVERSED = 'reversed'; |
| 21 | |
| 22 | /** |
| 23 | * Get default migration status |
| 24 | */ |
| 25 | public static function getDefault(): string |
| 26 | { |
| 27 | return MigrationLogStatus::FAILED; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Get all migration statuses |
| 32 | */ |
| 33 | public static function getAll(): array |
| 34 | { |
| 35 | return [ |
| 36 | MigrationLogStatus::SUCCESS => esc_html__('Success', 'give'), |
| 37 | MigrationLogStatus::FAILED => esc_html__('Failed', 'give'), |
| 38 | MigrationLogStatus::PENDING => esc_html__('Pending', 'give'), |
| 39 | MigrationLogStatus::RUNNING => esc_html__('Running', 'give'), |
| 40 | MigrationLogStatus::INCOMPLETE => esc_html__('Incomplete', 'give'), |
| 41 | MigrationLogStatus::REVERSED => esc_html__('Pending', 'give'), |
| 42 | ]; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Check if value is a valid migration status |
| 47 | */ |
| 48 | public static function isValid(string $status): bool |
| 49 | { |
| 50 | return array_key_exists($status, self::getAll()); |
| 51 | } |
| 52 | } |
| 53 |