Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 33 |
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 |
||
29 | public function buildForm(FormInterface $form) |
||
30 | { |
||
31 | $requiredData = $form->addChild($this->getElement('nested_fieldset', [ |
||
32 | 'name' => 'required_data', |
||
33 | 'label' => 'common.fieldset.general' |
||
34 | ])); |
||
35 | |||
36 | $languageData = $requiredData->addChild($this->getElement('language_fieldset', [ |
||
37 | 'name' => 'translations', |
||
38 | 'label' => 'common.fieldset.translations', |
||
39 | 'transformer' => $this->getRepositoryTransformer('translation', $this->get('layout_box.repository')) |
||
40 | ])); |
||
41 | |||
42 | $languageData->addChild($this->getElement('text_field', [ |
||
43 | 'name' => 'name', |
||
44 | 'label' => 'layout_box.label.name', |
||
45 | 'rules' => [ |
||
46 | $this->getRule('required') |
||
47 | ], |
||
48 | ])); |
||
49 | |||
50 | $languageData->addChild($this->getElement('rich_text_editor', [ |
||
51 | 'name' => 'content', |
||
52 | 'label' => 'layout_box.label.content' |
||
53 | ])); |
||
54 | |||
55 | $requiredData->addChild($this->getElement('text_field', [ |
||
56 | 'name' => 'identifier', |
||
57 | 'label' => 'layout_box.label.identifier', |
||
58 | 'rules' => [ |
||
59 | $this->getRule('required') |
||
60 | ], |
||
61 | ])); |
||
62 | |||
63 | $requiredData->addChild($this->getElement('select', [ |
||
64 | 'name' => 'boxType', |
||
65 | 'label' => 'layout_box.label.type', |
||
66 | 'default' => $this->getDefaultLayoutBoxType() |
||
67 | ])); |
||
68 | |||
69 | $requiredData->addChild($this->getElement('multi_select', [ |
||
70 | 'name' => 'clientGroups', |
||
71 | 'label' => 'layout_box.label.client_groups', |
||
72 | 'options' => $this->get('client_group.dataset.admin')->getResult('select'), |
||
73 | 'transformer' => $this->getRepositoryTransformer('collection', $this->get('client_group.repository')), |
||
74 | ])); |
||
75 | |||
76 | $form->addFilter($this->getFilter('no_code')); |
||
77 | $form->addFilter($this->getFilter('trim')); |
||
78 | $form->addFilter($this->getFilter('secure')); |
||
79 | } |
||
80 | |||
88 |