@@ -16,7 +16,7 @@ class AddNode extends Node
1616 public function __construct (private int $ value )
1717 {
1818 }
19-
19+
2020 public function run (WorkflowState $ state ): WorkflowState
2121 {
2222 $ current = $ state ->get ('value ' , 0 );
@@ -33,7 +33,7 @@ class MultiplyNode extends Node
3333 public function __construct (private int $ value )
3434 {
3535 }
36-
36+
3737 public function run (WorkflowState $ state ): WorkflowState
3838 {
3939 $ current = $ state ->get ('value ' , 0 );
@@ -50,7 +50,7 @@ class SubtractNode extends Node
5050 public function __construct (private int $ value )
5151 {
5252 }
53-
53+
5454 public function run (WorkflowState $ state ): WorkflowState
5555 {
5656 $ current = $ state ->get ('value ' , 0 );
@@ -94,26 +94,26 @@ public function nodes(): array
9494 'finish_odd ' => new FinishOddNode ()
9595 ];
9696 }
97-
97+
9898 public function edges (): array
9999 {
100100 return [
101101 // ((startingValue + 1) * 3) * 3) - 1
102102 new Edge ('add1 ' , 'multiply3_first ' ),
103103 new Edge ('multiply3_first ' , 'multiply3_second ' ),
104104 new Edge ('multiply3_second ' , 'sub1 ' ),
105-
105+
106106 // Branch based on even/odd
107- new Edge ('sub1 ' , 'finish_even ' , fn ($ state ) => $ state ->get ('value ' ) % 2 === 0 ),
108- new Edge ('sub1 ' , 'finish_odd ' , fn ($ state ) => $ state ->get ('value ' ) % 2 !== 0 )
107+ new Edge ('sub1 ' , 'finish_even ' , fn ($ state ) => $ state ->get ('value ' ) % 2 === 0 ),
108+ new Edge ('sub1 ' , 'finish_odd ' , fn ($ state ) => $ state ->get ('value ' ) % 2 !== 0 )
109109 ];
110110 }
111-
111+
112112 protected function start (): string
113113 {
114114 return 'add1 ' ;
115115 }
116-
116+
117117 protected function end (): array
118118 {
119119 return ['finish_even ' , 'finish_odd ' ];
@@ -125,30 +125,30 @@ class WorkflowStringKeysTest extends TestCase
125125 public function test_workflow_with_string_keys (): void
126126 {
127127 $ workflow = new CalculatorWorkflow ();
128-
128+
129129 // Test with initial value 2: ((2 + 1) * 3) * 3) - 1 = 26 (even)
130130 $ initialState = new WorkflowState (['value ' => 2 ]);
131131 $ result = $ workflow ->run ($ initialState );
132-
132+
133133 $ this ->assertEquals (26 , $ result ->get ('value ' ));
134134 $ this ->assertEquals ('even ' , $ result ->get ('result_type ' ));
135135 $ this ->assertContains ('Added 1 ' , $ result ->get ('history ' ));
136136 $ this ->assertContains ('Multiplied by 3 ' , $ result ->get ('history ' ));
137137 $ this ->assertContains ('Subtracted 1 ' , $ result ->get ('history ' ));
138138 }
139-
139+
140140 public function test_workflow_with_string_keys_odd_result (): void
141141 {
142142 $ workflow = new CalculatorWorkflow ();
143-
143+
144144 // Test with initial value 1: ((1 + 1) * 3) * 3) - 1 = 17 (odd)
145145 $ initialState = new WorkflowState (['value ' => 1 ]);
146146 $ result = $ workflow ->run ($ initialState );
147-
147+
148148 $ this ->assertEquals (17 , $ result ->get ('value ' ));
149149 $ this ->assertEquals ('odd ' , $ result ->get ('result_type ' ));
150150 }
151-
151+
152152 public function test_programmatic_workflow_with_string_keys (): void
153153 {
154154 $ workflow = new Workflow ();
@@ -160,21 +160,21 @@ public function test_programmatic_workflow_with_string_keys(): void
160160 ])
161161 ->addEdges ([
162162 new Edge ('add1 ' , 'multiply2 ' ),
163- new Edge ('multiply2 ' , 'finish_even ' , fn ($ state ) => $ state ->get ('value ' ) % 2 === 0 ),
164- new Edge ('multiply2 ' , 'finish_odd ' , fn ($ state ) => $ state ->get ('value ' ) % 2 !== 0 )
163+ new Edge ('multiply2 ' , 'finish_even ' , fn ($ state ) => $ state ->get ('value ' ) % 2 === 0 ),
164+ new Edge ('multiply2 ' , 'finish_odd ' , fn ($ state ) => $ state ->get ('value ' ) % 2 !== 0 )
165165 ])
166166 ->setStart ('add1 ' )
167167 ->setEnd ('finish_even ' )
168168 ->setEnd ('finish_odd ' );
169-
169+
170170 // Test with initial value 3: (3 + 1) * 2 = 8 (even)
171171 $ initialState = new WorkflowState (['value ' => 3 ]);
172172 $ result = $ workflow ->run ($ initialState );
173-
173+
174174 $ this ->assertEquals (8 , $ result ->get ('value ' ));
175175 $ this ->assertEquals ('even ' , $ result ->get ('result_type ' ));
176176 }
177-
177+
178178 public function test_mermaid_export_with_string_keys (): void
179179 {
180180 $ workflow = new Workflow ();
@@ -189,13 +189,13 @@ public function test_mermaid_export_with_string_keys(): void
189189 ])
190190 ->setStart ('start ' )
191191 ->setEnd ('finish ' );
192-
192+
193193 $ export = $ workflow ->export ();
194-
194+
195195 $ this ->assertStringContainsString ('start --> middle ' , $ export );
196196 $ this ->assertStringContainsString ('middle --> finish ' , $ export );
197197 }
198-
198+
199199 public function test_backward_compatibility_with_class_names (): void
200200 {
201201 // This test ensures the old behavior still works
@@ -205,12 +205,12 @@ public function test_backward_compatibility_with_class_names(): void
205205 ->addEdge (new Edge (StartNode::class, FinishNode::class))
206206 ->setStart (StartNode::class)
207207 ->setEnd (FinishNode::class);
208-
208+
209209 $ result = $ workflow ->run ();
210-
210+
211211 $ this ->assertEquals ('end ' , $ result ->get ('step ' ));
212212 }
213-
213+
214214 public function test_mixed_mode_nodes_and_edges (): void
215215 {
216216 // Test mixing both approaches - indexed array with class name edges
@@ -226,10 +226,10 @@ public function test_mixed_mode_nodes_and_edges(): void
226226 ])
227227 ->setStart (StartNode::class)
228228 ->setEnd (FinishNode::class);
229-
229+
230230 $ result = $ workflow ->run ();
231-
231+
232232 $ this ->assertEquals ('end ' , $ result ->get ('step ' ));
233233 $ this ->assertEquals (1 , $ result ->get ('counter ' ));
234234 }
235- }
235+ }
0 commit comments