Skip to content

Commit 42a6cee

Browse files
committed
Refactor Action class to use ActionState enum
1 parent b9b7cbd commit 42a6cee

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/Action.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Safemood\Workflow;
44

5+
use Safemood\Workflow\Enums\ActionState;
6+
57
abstract class Action
68
{
79
private $state;
@@ -19,20 +21,20 @@ abstract public function handle(array &$context);
1921
/**
2022
* Get the state of the action.
2123
*
22-
* @return mixed
24+
* @return ActionState|null
2325
*/
24-
public function getState()
26+
public function getState(): ?ActionState
2527
{
2628
return $this->state;
2729
}
2830

2931
/**
3032
* Set the state of the action.
3133
*
32-
* @param mixed $state
34+
* @param ActionState $state
3335
* @return void
3436
*/
35-
public function setState($state)
37+
public function setState(ActionState $state): void
3638
{
3739
$this->state = $state;
3840
}
@@ -42,7 +44,7 @@ public function setState($state)
4244
*
4345
* @return \Exception|null
4446
*/
45-
public function getException()
47+
public function getException(): ?\Exception
4648
{
4749
return $this->exception;
4850
}
@@ -53,7 +55,7 @@ public function getException()
5355
* @param \Exception|null $exception
5456
* @return void
5557
*/
56-
public function setException($exception)
58+
public function setException(?\Exception $exception): void
5759
{
5860
$this->exception = $exception;
5961
}

src/Enums/ActionState.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22

33
namespace Safemood\Workflow\Enums;
44

5-
class ActionState
5+
enum ActionState: string
66
{
7-
const PENDING = 'pending';
8-
9-
const RUNNING = 'running';
10-
11-
const SUCCESS = 'success';
12-
13-
const FAILED = 'failed';
7+
case PENDING = 'pending';
8+
case RUNNING = 'running';
9+
case SUCCESS = 'success';
10+
case FAILED = 'failed';
1411
}

0 commit comments

Comments
 (0)