Conditions | 11 |
Paths | 8 |
Total Lines | 58 |
Code Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
43 | public function process(ContainerBuilder $container) |
||
44 | { |
||
45 | if (false === $container->hasDefinition(static::WORKFLOW_REGISTRY_ID)) { |
||
46 | return; |
||
47 | } |
||
48 | |||
49 | if (false === $container->hasDefinition('gtt.workflow.transition_scheduler')) { |
||
50 | return; |
||
51 | } |
||
52 | |||
53 | $subjectClassesWithSubjectFromDomain = $container->getParameter('gtt.workflow.subject_classes_with_subject_from_domain'); |
||
54 | $workflowsWithScheduling = $container->getParameter('gtt.workflow.workflows_with_scheduling'); |
||
55 | |||
56 | $registryDefinition = $container->getDefinition(self::WORKFLOW_REGISTRY_ID); |
||
57 | foreach ($registryDefinition->getMethodCalls() as $call) { |
||
58 | if ($call[0] == self::WORKFLOW_REGISTRY_ADD_WORKFLOW_METHOD_NAME) { |
||
59 | $callArgs = $call[1]; |
||
60 | |||
61 | if (count($callArgs) != 2 || !$callArgs[0] instanceof Reference || !is_string($callArgs[1])) { |
||
62 | throw new RuntimeException( |
||
63 | sprintf( |
||
64 | 'Workflow registry service have unsupported signature for "%s" method', |
||
65 | self::WORKFLOW_REGISTRY_ADD_WORKFLOW_METHOD_NAME |
||
66 | ) |
||
67 | ); |
||
68 | } |
||
69 | |||
70 | /** @var Reference $workflowReference */ |
||
71 | $workflowReference = $callArgs[0]; |
||
72 | $workflowSupportedClass = $callArgs[1]; |
||
73 | |||
74 | $workflowIdWithPrefix = (string) $workflowReference; |
||
75 | if (substr($workflowIdWithPrefix, 0, strlen(self::WORKFLOW_ID_PREFIX)) != self::WORKFLOW_ID_PREFIX) { |
||
76 | throw new RuntimeException( |
||
77 | sprintf( |
||
78 | "Workflow registry works with workflow id '%s'in unsupported format", |
||
79 | $workflowIdWithPrefix |
||
80 | ) |
||
81 | ); |
||
82 | } |
||
83 | |||
84 | $workflowId = substr($workflowIdWithPrefix, strlen(self::WORKFLOW_ID_PREFIX)); |
||
85 | |||
86 | if (in_array($workflowId, $workflowsWithScheduling) && |
||
87 | !in_array(ltrim($workflowSupportedClass, "\\"), $subjectClassesWithSubjectFromDomain)) { |
||
88 | throw new InvalidConfigurationException( |
||
89 | sprintf( |
||
90 | 'Workflow "%s" configured to use scheduler so all the supported subject classes for it'. |
||
91 | 'must be configured with "subject_from_domain" option under "subject_manipulator". '. |
||
92 | 'This option for "%s" class is missing.', |
||
93 | $workflowId, |
||
94 | $workflowSupportedClass |
||
95 | ) |
||
96 | ); |
||
97 | } |
||
98 | } |
||
99 | } |
||
100 | } |
||
101 | } |