| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class for the smart link status enum. |
| 4 |
* |
| 5 |
* @package Parsely |
| 6 |
* @since 3.19.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace Parsely\Models; |
| 10 |
|
| 11 |
/** |
| 12 |
* Smart Link Status enum. |
| 13 |
* |
| 14 |
* Since enum classes are only available since PHP 8, we need to use a class to |
| 15 |
* simulate an enum. |
| 16 |
* |
| 17 |
* @since 3.19.0 |
| 18 |
*/ |
| 19 |
class Smart_Link_Status { |
| 20 |
const ALL = 'all'; |
| 21 |
const APPLIED = 'applied'; |
| 22 |
const PENDING = 'pending'; |
| 23 |
|
| 24 |
/** |
| 25 |
* Checks if a status is valid. |
| 26 |
* |
| 27 |
* @since 3.19.0 |
| 28 |
* |
| 29 |
* @param string $status The status to check. |
| 30 |
* @return bool True if the status is valid, false otherwise. |
| 31 |
*/ |
| 32 |
public static function is_valid_status( string $status ): bool { |
| 33 |
return in_array( $status, self::get_all_statuses(), true ); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Gets all the statuses. |
| 38 |
* |
| 39 |
* @since 3.19.0 |
| 40 |
* |
| 41 |
* @return array<string> The statuses. |
| 42 |
*/ |
| 43 |
public static function get_all_statuses(): array { |
| 44 |
return array( self::ALL, self::APPLIED, self::PENDING ); |
| 45 |
} |
| 46 |
} |
| 47 |
|