Skip to content

Commit 9fc62f1

Browse files
lam0819github-actions[bot]
authored andcommitted
Fix styling
1 parent 14ae146 commit 9fc62f1

File tree

13 files changed

+202
-106
lines changed

13 files changed

+202
-106
lines changed

src/Actions/ConditionAction.php

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

33
namespace SolutionForest\WorkflowMastery\Actions;
44

5-
use SolutionForest\WorkflowMastery\Attributes\{WorkflowStep, Condition};
5+
use SolutionForest\WorkflowMastery\Attributes\Condition;
6+
use SolutionForest\WorkflowMastery\Attributes\WorkflowStep;
67
use SolutionForest\WorkflowMastery\Core\ActionResult;
78
use SolutionForest\WorkflowMastery\Core\WorkflowContext;
89

@@ -32,13 +33,13 @@ protected function doExecute(WorkflowContext $context): ActionResult
3233
$onTrue = $this->getConfig('on_true', null);
3334
$onFalse = $this->getConfig('on_false', null);
3435

35-
if (!$condition) {
36+
if (! $condition) {
3637
return ActionResult::failure('Condition is required');
3738
}
3839

3940
try {
4041
$result = $this->evaluateCondition($condition, $context->getAllData());
41-
42+
4243
return ActionResult::success([
4344
'condition' => $condition,
4445
'result' => $result,
@@ -67,7 +68,7 @@ private function evaluateCondition(string $condition, array $data): bool
6768
$leftValue = $this->getValue($left, $data);
6869
$rightValue = $this->getValue($right, $data);
6970

70-
return match($operator) {
71+
return match ($operator) {
7172
'=' => $leftValue == $rightValue,
7273
'!=' => $leftValue != $rightValue,
7374
'>' => $leftValue > $rightValue,
@@ -106,7 +107,7 @@ private function getValue(string $expression, array $data): mixed
106107
}
107108

108109
// Check for boolean literals
109-
return match(strtolower($expression)) {
110+
return match (strtolower($expression)) {
110111
'true', 'yes' => true,
111112
'false', 'no' => false,
112113
'null', 'empty' => null,

src/Actions/HttpAction.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
namespace SolutionForest\WorkflowMastery\Actions;
44

5-
use SolutionForest\WorkflowMastery\Attributes\{WorkflowStep, Retry, Timeout};
5+
use Illuminate\Support\Facades\Http;
6+
use SolutionForest\WorkflowMastery\Attributes\Retry;
7+
use SolutionForest\WorkflowMastery\Attributes\Timeout;
8+
use SolutionForest\WorkflowMastery\Attributes\WorkflowStep;
69
use SolutionForest\WorkflowMastery\Core\ActionResult;
710
use SolutionForest\WorkflowMastery\Core\WorkflowContext;
8-
use Illuminate\Support\Facades\Http;
911

1012
/**
1113
* HTTP request action with PHP 8.3+ features
@@ -37,7 +39,7 @@ protected function doExecute(WorkflowContext $context): ActionResult
3739
$headers = $this->getConfig('headers', []);
3840
$timeout = $this->getConfig('timeout', 30);
3941

40-
if (!$url) {
42+
if (! $url) {
4143
return ActionResult::failure('URL is required for HTTP action');
4244
}
4345

@@ -46,7 +48,7 @@ protected function doExecute(WorkflowContext $context): ActionResult
4648
$data = $this->processArrayTemplates($data, $context->getAllData());
4749

4850
try {
49-
$response = match($method) {
51+
$response = match ($method) {
5052
'GET' => Http::timeout($timeout)->withHeaders($headers)->get($url, $data),
5153
'POST' => Http::timeout($timeout)->withHeaders($headers)->post($url, $data),
5254
'PUT' => Http::timeout($timeout)->withHeaders($headers)->put($url, $data),
@@ -106,6 +108,7 @@ private function processArrayTemplates(array $array, array $data): array
106108
$result[$key] = $value;
107109
}
108110
}
111+
109112
return $result;
110113
}
111114
}

src/Attributes/Condition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/**
88
* Condition attribute for conditional execution
9-
*
9+
*
1010
* @example
1111
* #[Condition('user.email is not null')]
1212
* #[Condition('order.amount > 100')]

src/Attributes/Retry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/**
88
* Retry configuration attribute
9-
*
9+
*
1010
* @example
1111
* #[Retry(attempts: 3)]
1212
* #[Retry(attempts: 5, backoff: 'exponential')]

src/Attributes/Timeout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/**
88
* Timeout configuration attribute
9-
*
9+
*
1010
* @example
1111
* #[Timeout(seconds: 30)]
1212
* #[Timeout(minutes: 5)]

src/Attributes/WorkflowStep.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/**
88
* Workflow step configuration attribute
9-
*
9+
*
1010
* @example
1111
* #[WorkflowStep(
1212
* id: 'send_email',

src/Core/WorkflowBuilder.php

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/**
88
* Fluent workflow builder for simplified workflow creation
9-
*
9+
*
1010
* @example
1111
* $workflow = WorkflowBuilder::create('user-onboarding')
1212
* ->description('Complete user onboarding process')
@@ -20,11 +20,17 @@
2020
class WorkflowBuilder
2121
{
2222
private string $name;
23+
2324
private string $version = '1.0';
25+
2426
private string $description = '';
27+
2528
private array $steps = [];
29+
2630
private array $transitions = [];
31+
2732
private array $metadata = [];
33+
2834
private array $conditionalSteps = [];
2935

3036
private function __construct(string $name)
@@ -46,6 +52,7 @@ public static function create(string $name): self
4652
public function description(string $description): self
4753
{
4854
$this->description = $description;
55+
4956
return $this;
5057
}
5158

@@ -55,6 +62,7 @@ public function description(string $description): self
5562
public function version(string $version): self
5663
{
5764
$this->version = $version;
65+
5866
return $this;
5967
}
6068

@@ -75,6 +83,7 @@ public function addStep(
7583
'timeout' => $timeout,
7684
'retry_attempts' => $retryAttempts,
7785
];
86+
7887
return $this;
7988
}
8089

@@ -87,7 +96,8 @@ public function startWith(
8796
?int $timeout = null,
8897
int $retryAttempts = 0
8998
): self {
90-
$stepId = 'step_' . (count($this->steps) + 1);
99+
$stepId = 'step_'.(count($this->steps) + 1);
100+
91101
return $this->addStep($stepId, $action, $config, $timeout, $retryAttempts);
92102
}
93103

@@ -100,7 +110,8 @@ public function then(
100110
?int $timeout = null,
101111
int $retryAttempts = 0
102112
): self {
103-
$stepId = 'step_' . (count($this->steps) + 1);
113+
$stepId = 'step_'.(count($this->steps) + 1);
114+
104115
return $this->addStep($stepId, $action, $config, $timeout, $retryAttempts);
105116
}
106117

@@ -112,12 +123,12 @@ public function when(string $condition, callable $callback): self
112123
$originalStepsCount = count($this->steps);
113124
$callback($this);
114125
$newStepsCount = count($this->steps);
115-
126+
116127
// Mark new steps as conditional
117128
for ($i = $originalStepsCount; $i < $newStepsCount; $i++) {
118129
$this->steps[$i]['condition'] = $condition;
119130
}
120-
131+
121132
return $this;
122133
}
123134

@@ -131,7 +142,7 @@ public function email(
131142
array $data = []
132143
): self {
133144
return $this->addStep(
134-
'email_' . count($this->steps),
145+
'email_'.count($this->steps),
135146
'SolutionForest\\WorkflowMastery\\Actions\\EmailAction',
136147
[
137148
'template' => $template,
@@ -145,14 +156,14 @@ public function email(
145156
/**
146157
* Add delay step (common pattern)
147158
*/
148-
public function delay(int $seconds = null, int $minutes = null, int $hours = null): self
159+
public function delay(?int $seconds = null, ?int $minutes = null, ?int $hours = null): self
149160
{
150161
$totalSeconds = $seconds ?? 0;
151162
$totalSeconds += ($minutes ?? 0) * 60;
152163
$totalSeconds += ($hours ?? 0) * 3600;
153164

154165
return $this->addStep(
155-
'delay_' . count($this->steps),
166+
'delay_'.count($this->steps),
156167
'SolutionForest\\WorkflowMastery\\Actions\\DelayAction',
157168
['seconds' => $totalSeconds]
158169
);
@@ -168,7 +179,7 @@ public function http(
168179
array $headers = []
169180
): self {
170181
return $this->addStep(
171-
'http_' . count($this->steps),
182+
'http_'.count($this->steps),
172183
'SolutionForest\\WorkflowMastery\\Actions\\HttpAction',
173184
[
174185
'url' => $url,
@@ -185,7 +196,7 @@ public function http(
185196
public function condition(string $condition): self
186197
{
187198
return $this->addStep(
188-
'condition_' . count($this->steps),
199+
'condition_'.count($this->steps),
189200
'SolutionForest\\WorkflowMastery\\Actions\\ConditionAction',
190201
['condition' => $condition]
191202
);
@@ -197,6 +208,7 @@ public function condition(string $condition): self
197208
public function withMetadata(array $metadata): self
198209
{
199210
$this->metadata = array_merge($this->metadata, $metadata);
211+
200212
return $this;
201213
}
202214

@@ -237,7 +249,7 @@ public function build(): WorkflowDefinition
237249
*/
238250
public static function quick(): QuickWorkflowBuilder
239251
{
240-
return new QuickWorkflowBuilder();
252+
return new QuickWorkflowBuilder;
241253
}
242254
}
243255

@@ -295,10 +307,10 @@ public function documentApproval(string $name = 'document-approval'): WorkflowBu
295307
subject: 'Document Review Request'
296308
)
297309
->addStep('review_document', 'App\\Actions\\ReviewDocumentAction')
298-
->when('review.approved', function($builder) {
310+
->when('review.approved', function ($builder) {
299311
$builder->addStep('approve_document', 'App\\Actions\\ApproveDocumentAction');
300312
})
301-
->when('review.rejected', function($builder) {
313+
->when('review.rejected', function ($builder) {
302314
$builder->addStep('reject_document', 'App\\Actions\\RejectDocumentAction');
303315
});
304316
}

src/Core/WorkflowContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function __construct(
1515
public array $data = [],
1616
public array $config = [],
1717
public ?WorkflowInstance $instance = null,
18-
public DateTime $executedAt = new DateTime()
18+
public DateTime $executedAt = new DateTime
1919
) {}
2020

2121
/**
@@ -72,7 +72,7 @@ public function with(string $key, mixed $value): self
7272
{
7373
$newData = $this->data;
7474
data_set($newData, $key, $value);
75-
75+
7676
return new self(
7777
workflowId: $this->workflowId,
7878
stepId: $this->stepId,

src/Core/WorkflowDefinition.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ private function processSteps(array $stepsData): array
116116
// Handle both Step objects and array data
117117
if ($stepData instanceof Step) {
118118
$steps[$stepData->getId()] = $stepData;
119+
119120
continue;
120121
}
121122

src/Core/WorkflowState.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function isFinished(): bool
3636
*/
3737
public function color(): string
3838
{
39-
return match($this) {
39+
return match ($this) {
4040
self::PENDING => 'gray',
4141
self::RUNNING => 'blue',
4242
self::WAITING => 'yellow',
@@ -52,7 +52,7 @@ public function color(): string
5252
*/
5353
public function icon(): string
5454
{
55-
return match($this) {
55+
return match ($this) {
5656
self::PENDING => '',
5757
self::RUNNING => '▶️',
5858
self::WAITING => '⏸️',
@@ -68,7 +68,7 @@ public function icon(): string
6868
*/
6969
public function canTransitionTo(self $state): bool
7070
{
71-
return match($this) {
71+
return match ($this) {
7272
self::PENDING => in_array($state, [self::RUNNING, self::CANCELLED]),
7373
self::RUNNING => in_array($state, [self::WAITING, self::PAUSED, self::COMPLETED, self::FAILED, self::CANCELLED]),
7474
self::WAITING => in_array($state, [self::RUNNING, self::FAILED, self::CANCELLED]),
@@ -82,7 +82,7 @@ public function canTransitionTo(self $state): bool
8282
*/
8383
public function label(): string
8484
{
85-
return match($this) {
85+
return match ($this) {
8686
self::PENDING => 'Pending',
8787
self::RUNNING => 'Running',
8888
self::WAITING => 'Waiting',

0 commit comments

Comments
 (0)