| Conditions | 3 |
| Paths | 1 |
| Total Lines | 65 |
| 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 |
||
| 109 | protected function configureFormFields(FormMapper $formMapper) |
||
| 110 | { |
||
| 111 | $isHorizontal = 'horizontal' == $this->getConfigurationPool()->getOption('form_type'); |
||
| 112 | $formMapper |
||
| 113 | ->with('group_post', [ |
||
| 114 | 'class' => 'col-md-8', |
||
| 115 | ]) |
||
| 116 | ->add('author', ModelListType::class) |
||
| 117 | ->add('title') |
||
| 118 | ->add('abstract', TextareaType::class, [ |
||
| 119 | 'attr' => ['rows' => 5], |
||
| 120 | ]) |
||
| 121 | ->add('content', FormatterType::class, [ |
||
| 122 | 'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(), |
||
| 123 | 'format_field' => 'contentFormatter', |
||
| 124 | 'source_field' => 'rawContent', |
||
| 125 | 'source_field_options' => [ |
||
| 126 | 'horizontal_input_wrapper_class' => $isHorizontal ? 'col-lg-12' : '', |
||
| 127 | 'attr' => ['class' => $isHorizontal ? 'span10 col-sm-10 col-md-10' : '', 'rows' => 20], |
||
| 128 | ], |
||
| 129 | 'ckeditor_context' => 'news', |
||
| 130 | 'target_field' => 'content', |
||
| 131 | 'listener' => true, |
||
| 132 | ]) |
||
| 133 | ->end() |
||
| 134 | ->with('group_status', [ |
||
| 135 | 'class' => 'col-md-4', |
||
| 136 | ]) |
||
| 137 | ->add('enabled', CheckboxType::class, ['required' => false]) |
||
| 138 | ->add('image', ModelListType::class, ['required' => false], [ |
||
| 139 | 'link_parameters' => [ |
||
| 140 | 'context' => 'news', |
||
| 141 | 'hide_context' => true, |
||
| 142 | ], |
||
| 143 | ]) |
||
| 144 | |||
| 145 | ->add('publicationDateStart', DateTimePickerType::class, [ |
||
| 146 | 'dp_side_by_side' => true, |
||
| 147 | ]) |
||
| 148 | ->add('commentsCloseAt', DateTimePickerType::class, [ |
||
| 149 | 'dp_side_by_side' => true, |
||
| 150 | 'required' => false, |
||
| 151 | ]) |
||
| 152 | ->add('commentsEnabled', CheckboxType::class, [ |
||
| 153 | 'required' => false, |
||
| 154 | ]) |
||
| 155 | ->add('commentsDefaultStatus', CommentStatusType::class, [ |
||
| 156 | 'expanded' => true, |
||
| 157 | ]) |
||
| 158 | ->end() |
||
| 159 | |||
| 160 | ->with('group_classification', [ |
||
| 161 | 'class' => 'col-md-4', |
||
| 162 | ]) |
||
| 163 | ->add('tags', ModelAutocompleteType::class, [ |
||
| 164 | 'property' => 'name', |
||
| 165 | 'multiple' => 'true', |
||
| 166 | 'required' => false, |
||
| 167 | ]) |
||
| 168 | ->add('collection', ModelListType::class, [ |
||
| 169 | 'required' => false, |
||
| 170 | ]) |
||
| 171 | ->end() |
||
| 172 | ; |
||
| 173 | } |
||
| 174 | |||
| 253 |