| 1 | <?php |
||
| 13 | class Action |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var array List of valid actions that can be called. |
||
| 17 | */ |
||
| 18 | private static $valid_actions = [ |
||
| 19 | 'set', |
||
| 20 | 'unset', |
||
| 21 | 'reset', |
||
| 22 | 'handle', |
||
| 23 | ]; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var string Action to be executed. |
||
| 27 | */ |
||
| 28 | private $action; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Action constructor. |
||
| 32 | * |
||
| 33 | * @param string $action |
||
| 34 | * |
||
| 35 | * @throws \InvalidArgumentException |
||
| 36 | */ |
||
| 37 | public function __construct($action = 'handle') |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Check if the current action is one of the passed ones. |
||
| 48 | * |
||
| 49 | * @param string|array $actions |
||
| 50 | * |
||
| 51 | * @return bool |
||
| 52 | */ |
||
| 53 | public function isAction($actions) |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Return the current action. |
||
| 60 | * |
||
| 61 | * @return string |
||
| 62 | */ |
||
| 63 | public function getAction() |
||
| 67 | } |
||
| 68 |