| Conditions | 3 |
| Paths | 1 |
| Total Lines | 55 |
| Code Lines | 41 |
| 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 |
||
| 101 | protected function configureFormFields(FormMapper $formMapper) |
||
| 102 | { |
||
| 103 | $isHorizontal = $this->getConfigurationPool()->getOption('form_type') == 'horizontal'; |
||
| 104 | $formMapper |
||
| 105 | ->with('group_post', array( |
||
| 106 | 'class' => 'col-md-8', |
||
| 107 | )) |
||
| 108 | ->add('author', 'sonata_type_model_list') |
||
| 109 | ->add('title') |
||
| 110 | ->add('abstract', null, array('attr' => array('rows' => 5))) |
||
| 111 | ->add('content', 'sonata_formatter_type', array( |
||
| 112 | 'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(), |
||
| 113 | 'format_field' => 'contentFormatter', |
||
| 114 | 'source_field' => 'rawContent', |
||
| 115 | 'source_field_options' => array( |
||
| 116 | 'horizontal_input_wrapper_class' => $isHorizontal ? 'col-lg-12' : '', |
||
| 117 | 'attr' => array('class' => $isHorizontal ? 'span10 col-sm-10 col-md-10' : '', 'rows' => 20), |
||
| 118 | ), |
||
| 119 | 'ckeditor_context' => 'news', |
||
| 120 | 'target_field' => 'content', |
||
| 121 | 'listener' => true, |
||
| 122 | )) |
||
| 123 | ->end() |
||
| 124 | ->with('group_status', array( |
||
| 125 | 'class' => 'col-md-4', |
||
| 126 | )) |
||
| 127 | ->add('enabled', null, array('required' => false)) |
||
| 128 | ->add('image', 'sonata_type_model_list', array('required' => false), array( |
||
| 129 | 'link_parameters' => array( |
||
| 130 | 'context' => 'news', |
||
| 131 | 'hide_context' => true, |
||
| 132 | ), |
||
| 133 | )) |
||
| 134 | |||
| 135 | ->add('publicationDateStart', 'sonata_type_datetime_picker', array('dp_side_by_side' => true)) |
||
| 136 | ->add('commentsCloseAt', 'sonata_type_datetime_picker', array( |
||
| 137 | 'dp_side_by_side' => true, |
||
| 138 | 'required' => false, |
||
| 139 | )) |
||
| 140 | ->add('commentsEnabled', null, array('required' => false)) |
||
| 141 | ->add('commentsDefaultStatus', 'sonata_news_comment_status', array('expanded' => true)) |
||
| 142 | ->end() |
||
| 143 | |||
| 144 | ->with('group_classification', array( |
||
| 145 | 'class' => 'col-md-4', |
||
| 146 | )) |
||
| 147 | ->add('tags', 'sonata_type_model_autocomplete', array( |
||
| 148 | 'property' => 'name', |
||
| 149 | 'multiple' => 'true', |
||
| 150 | 'required' => false, |
||
| 151 | )) |
||
| 152 | ->add('collection', 'sonata_type_model_list', array('required' => false)) |
||
| 153 | ->end() |
||
| 154 | ; |
||
| 155 | } |
||
| 156 | |||
| 235 |