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