Conditions | 1 |
Paths | 1 |
Total Lines | 101 |
Code Lines | 74 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
86 | protected function configureFormFields(FormMapper $form): void |
||
87 | { |
||
88 | $form |
||
89 | ->add('serie', ModelAutocompleteType::class, [ |
||
90 | 'property' => 'libSerie', |
||
91 | 'label' => 'label.serie', |
||
92 | 'required' => false, |
||
93 | ]) |
||
94 | ->add('libGameEn', TextType::class, [ |
||
95 | 'label' => 'label.name.en', |
||
96 | 'required' => true, |
||
97 | ]) |
||
98 | ->add('libGameFr', TextType::class, [ |
||
99 | 'label' => 'label.name.fr', |
||
100 | 'required' => false, |
||
101 | ]) |
||
102 | ->add('rules', null, ['required' => false, 'expanded' => false, 'label' => 'label.rules']) |
||
103 | ->add('badge', ModelListType::class, [ |
||
104 | 'btn_add' => true, |
||
105 | 'btn_list' => true, |
||
106 | 'btn_edit' => false, |
||
107 | 'btn_delete' => false, |
||
108 | 'btn_catalogue' => true, |
||
109 | 'label' => 'label.badge', |
||
110 | ]) |
||
111 | ->add('forum', ModelListType::class, [ |
||
112 | 'btn_add' => true, |
||
113 | 'btn_list' => true, |
||
114 | 'btn_edit' => false, |
||
115 | 'btn_delete' => false, |
||
116 | 'btn_catalogue' => true, |
||
117 | 'label' => 'label.forum', |
||
118 | ]) |
||
119 | ->add('picture', TextType::class, [ |
||
120 | 'label' => 'label.picture', |
||
121 | 'required' => false, |
||
122 | ]) |
||
123 | ->add('downloadUrl', TextType::class, [ |
||
124 | 'label' => 'label.downloadUrl', |
||
125 | 'required' => false, |
||
126 | ]) |
||
127 | ->add( |
||
128 | 'status', |
||
129 | ChoiceType::class, |
||
130 | [ |
||
131 | 'label' => 'label.status', |
||
132 | 'choices' => GameStatus::getStatusChoices(), |
||
133 | ] |
||
134 | ) |
||
135 | ->add('publishedAt', DateType::class, [ |
||
136 | 'label' => 'label.publishedAt', |
||
137 | 'required' => false, |
||
138 | 'years' => range(2004, date('Y')) |
||
139 | ]) |
||
140 | ->add('isRank', CheckboxType::class, [ |
||
141 | 'label' => 'label.boolRanking', |
||
142 | 'required' => false, |
||
143 | ]) |
||
144 | ->add( |
||
145 | 'platforms', |
||
146 | null, |
||
147 | [ |
||
148 | 'label' => 'label.platforms', |
||
149 | 'required' => false, |
||
150 | 'expanded' => false, |
||
151 | 'query_builder' => |
||
152 | function ($er) { |
||
153 | $qb = $er->createQueryBuilder('p'); |
||
154 | $qb->orderBy('p.libPlatform', 'ASC'); |
||
155 | return $qb; |
||
156 | } |
||
157 | ] |
||
158 | ) |
||
159 | ->end() |
||
160 | ->with('label.groups') |
||
161 | ->add( |
||
162 | 'groups', |
||
163 | CollectionType::class, |
||
164 | array( |
||
165 | 'label' => 'label.groups', |
||
166 | 'by_reference' => false, |
||
167 | 'type_options' => array( |
||
168 | // Prevents the "Delete" option from being displayed |
||
169 | 'delete' => true, |
||
170 | 'delete_options' => array( |
||
171 | // You may otherwise choose to put the field but hide it |
||
172 | 'type' => CheckboxType::class, |
||
173 | // In that case, you need to fill in the options as well |
||
174 | 'type_options' => array( |
||
175 | 'mapped' => false, |
||
176 | 'required' => false, |
||
177 | ) |
||
178 | ) |
||
179 | ), |
||
180 | ), |
||
181 | array( |
||
182 | 'edit' => 'inline', |
||
183 | 'inline' => 'table', |
||
184 | ) |
||
185 | ) |
||
186 | ->end(); |
||
187 | } |
||
313 |