Skip to content

Commit 2af9388

Browse files
author
Willem Oostendorp
committed
Fixed some typos and styling issues
1 parent be4bc58 commit 2af9388

File tree

1 file changed

+44
-34
lines changed

1 file changed

+44
-34
lines changed

src/WorkflowRegistry.php

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore;
1212
use Symfony\Component\Workflow\Registry;
1313
use Symfony\Component\Workflow\StateMachine;
14+
use Symfony\Component\Workflow\SupportStrategy\SupportStrategyInterface;
1415
use Symfony\Component\Workflow\Transition;
1516
use Symfony\Component\Workflow\Workflow;
1617
use Symfony\Component\Workflow\SupportStrategy\ClassInstanceSupportStrategy;
@@ -21,7 +22,7 @@
2122
class WorkflowRegistry
2223
{
2324
/**
24-
* @var Symfony\Component\Workflow\Registry
25+
* @var Registry
2526
*/
2627
private $registry;
2728

@@ -35,13 +36,19 @@ class WorkflowRegistry
3536
*/
3637
private $dispatcher;
3738

39+
/**
40+
* WorkflowRegistry constructor
41+
*
42+
* @param array $config
43+
* @throws \ReflectionException
44+
*/
3845
public function __construct(array $config)
3946
{
40-
$this->registry = new Registry();
41-
$this->config = $config;
42-
$this->dispatcher = new EventDispatcher();
47+
$this->registry = new Registry();
48+
$this->config = $config;
49+
$this->dispatcher = new EventDispatcher();
4350

44-
$subscriber = new WorkflowSubscriber();
51+
$subscriber = new WorkflowSubscriber();
4552
$this->dispatcher->addSubscriber($subscriber);
4653

4754
foreach ($this->config as $name => $workflowData) {
@@ -55,9 +62,9 @@ public function __construct(array $config)
5562
$builder->addTransition(new Transition($transitionName, $transition['from'], $transition['to']));
5663
}
5764

58-
$definition = $builder->build();
59-
$markingStore = $this->getMakingStoreInstance($workflowData);
60-
$workflow = $this->getWorkflowInstance($name, $workflowData, $definition, $markingStore);
65+
$definition = $builder->build();
66+
$markingStore = $this->getMarkingStoreInstance($workflowData);
67+
$workflow = $this->getWorkflowInstance($name, $workflowData, $definition, $markingStore);
6168

6269
foreach ($workflowData['supports'] as $supportedClass) {
6370
$this->add($workflow, $supportedClass);
@@ -66,7 +73,8 @@ public function __construct(array $config)
6673
}
6774

6875
/**
69-
* Return the $subject workflo
76+
* Return the $subject workflow
77+
*
7078
* @param object $subject
7179
* @param string $workflowName
7280
* @return Workflow
@@ -78,31 +86,36 @@ public function get($subject, $workflowName = null)
7886

7987
/**
8088
* Add a workflow to the subject
81-
* @param Workflow $workflow
82-
* @param Symfony\Component\Workflow\SupportStrategy\SupportStrategyInterface $supportStrategy
89+
*
90+
* @param Workflow $workflow
91+
* @param SupportStrategyInterface $supportStrategy
8392
*/
84-
public function add(Workflow $workflow, $supportStrategy)
93+
public function add(Workflow $workflow, SupportStrategyInterface $supportStrategy)
8594
{
86-
return $this->registry->add($workflow, new ClassInstanceSupportStrategy($supportStrategy));
95+
$this->registry->add($workflow, new ClassInstanceSupportStrategy($supportStrategy));
8796
}
8897

8998
/**
9099
* Return the workflow instance
91100
*
92-
* @param String $name
93-
* @param array $workflowData
94-
* @param Symfony\Component\Workflow\Definition $definition
95-
* @param Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface $makingStore
96-
* @return Symfony\Component\Workflow\Workflow
101+
* @param String $name
102+
* @param array $workflowData
103+
* @param Definition $definition
104+
* @param MarkingStoreInterface $markingStore
105+
* @return Workflow
97106
*/
98-
private function getWorkflowInstance($name, $workflowData, Definition $definition, MarkingStoreInterface $markingStore)
99-
{
107+
private function getWorkflowInstance(
108+
$name,
109+
array $workflowData,
110+
Definition $definition,
111+
MarkingStoreInterface $markingStore
112+
) {
100113
$type = isset($workflowData['type']) ? $workflowData['type'] : 'workflow';
101114
$className = Workflow::class;
102115

103116
if ($type === 'state_machine') {
104117
$className = StateMachine::class;
105-
} else if (isset($workflowData['class'])) {
118+
} elseif (isset($workflowData['class'])) {
106119
$className = $workflowData['class'];
107120
}
108121

@@ -112,24 +125,21 @@ private function getWorkflowInstance($name, $workflowData, Definition $definitio
112125
/**
113126
* Return the making store instance
114127
*
115-
* @param array $makingStoreData
116-
* @return Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface
128+
* @param array $workflowData
129+
* @return MarkingStoreInterface
130+
* @throws \ReflectionException
117131
*/
118-
private function getMakingStoreInstance($workflowData)
132+
private function getMarkingStoreInstance(array $workflowData)
119133
{
120-
$makingStoreData = isset($workflowData['marking_store']) ? $workflowData['marking_store'] : [];
121-
$type = isset($makingStoreData['type']) ? $makingStoreData['type'] : 'single_state';
122-
$className = SingleStateMarkingStore::class;
123-
$arguments = [];
134+
$markingStoreData = isset($workflowData['marking_store']) ? $workflowData['marking_store'] : [];
135+
$type = isset($markingStoreData['type']) ? $markingStoreData['type'] : 'single_state';
136+
$className = SingleStateMarkingStore::class;
137+
$arguments = isset($markingStoreData['arguments']) ? $markingStoreData['arguments'] : [];
124138

125139
if ($type === 'multiple_state') {
126140
$className = MultipleStateMarkingStore::class;
127-
} else if (isset($workflowData['class'])) {
128-
$className = $workflowData['class'];
129-
}
130-
131-
if (isset($makingStoreData['arguments'])) {
132-
$arguments = $makingStoreData['arguments'];
141+
} elseif (isset($markingStoreData['class'])) {
142+
$className = $markingStoreData['class'];
133143
}
134144

135145
$class = new \ReflectionClass($className);

0 commit comments

Comments
 (0)