Conditions | 6 |
Paths | 4 |
Total Lines | 53 |
Code Lines | 40 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
83 | public function configureFields(string $pageName): iterable |
||
84 | { |
||
85 | if (Crud::PAGE_DETAIL === $pageName) { |
||
86 | return [ |
||
87 | Field::new('name'), |
||
88 | Field::new('username'), |
||
89 | Field::new('status'), |
||
90 | Field::new('createTime'), |
||
91 | Field::new('startTime'), |
||
92 | Field::new('endTime'), |
||
93 | Field::new('failTime'), |
||
94 | TextField::new('Files')->formatValue(function ($value, EtlExecution $entity) { |
||
95 | $urls = []; |
||
96 | if ($this->isGranted(EtlExecutionVoter::DOWNLOAD, EtlExecution::class)) { |
||
97 | $files = $this->chainWorkDirManager->listFiles($entity); |
||
98 | foreach ($files as $file) { |
||
99 | $url = $this->adminUrlGenerator |
||
100 | ->setRoute("etl_execution_download_file", ['execution' => $entity->getId(), 'filename' => $file]) |
||
101 | ->generateUrl(); |
||
102 | |||
103 | $urls[$url] = $file; |
||
104 | } |
||
105 | } |
||
106 | |||
107 | return $urls; |
||
108 | })->setTemplatePath('@Oliverde8PhpEtl/fields/files.html.twig'), |
||
109 | CodeEditorField::new('inputData')->setTemplatePath('@Oliverde8PhpEtl/fields/code_editor.html.twig'), |
||
110 | CodeEditorField::new('inputOptions')->setTemplatePath('@Oliverde8PhpEtl/fields/code_editor.html.twig'), |
||
111 | CodeEditorField::new('definition')->setTemplatePath('@Oliverde8PhpEtl/fields/code_editor.html.twig'), |
||
112 | CodeEditorField::new('errorMessage')->setTemplatePath('@Oliverde8PhpEtl/fields/code_editor.html.twig'), |
||
113 | ]; |
||
114 | } |
||
115 | if (Crud::PAGE_INDEX === $pageName) { |
||
116 | return [ |
||
117 | Field::new('id'), |
||
118 | Field::new('name'), |
||
119 | Field::new('username'), |
||
120 | TextField::new('status')->setTemplatePath('@Oliverde8PhpEtl/fields/status.html.twig'), |
||
121 | Field::new('createTime'), |
||
122 | Field::new('startTime'), |
||
123 | Field::new('endTime'), |
||
124 | ]; |
||
125 | } |
||
126 | if (Crud::PAGE_NEW === $pageName) { |
||
127 | return [ |
||
128 | ChoiceField::new('name', 'Chain Name') |
||
129 | ->setChoices($this->getChainOptions()), |
||
130 | CodeEditorField::new('inputData'), |
||
131 | CodeEditorField::new('inputOptions'), |
||
132 | ]; |
||
133 | } |
||
134 | |||
135 | return parent::configureFields($pageName); |
||
136 | } |
||
185 |