| 1 | <?php declare(strict_types=1); |
||
| 15 | class Action |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var array List of valid actions that can be called. |
||
| 19 | */ |
||
| 20 | private static $valid_actions = [ |
||
| 21 | 'set', |
||
| 22 | 'unset', |
||
| 23 | 'reset', |
||
| 24 | 'handle', |
||
| 25 | 'cron', |
||
| 26 | ]; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var string Action to be executed. |
||
| 30 | */ |
||
| 31 | private $action; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Action constructor. |
||
| 35 | * |
||
| 36 | * @param string $action |
||
| 37 | * |
||
| 38 | * @throws \TelegramBot\TelegramBotManager\Exception\InvalidActionException |
||
| 39 | */ |
||
| 40 | public function __construct($action = 'handle') |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Check if the current action is one of the passed ones. |
||
| 51 | * |
||
| 52 | * @param string|array $actions |
||
| 53 | * |
||
| 54 | * @return bool |
||
| 55 | */ |
||
| 56 | public function isAction($actions): bool |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Return the current action. |
||
| 63 | * |
||
| 64 | * @return string |
||
| 65 | */ |
||
| 66 | public function getAction(): string |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Return a list of valid actions. |
||
| 73 | * |
||
| 74 | * @return array |
||
| 75 | */ |
||
| 76 | public static function getValidActions(): array |
||
| 80 | } |
||
| 81 |