Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 45 |
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 |
||
46 | public function TypoForm() |
||
47 | { |
||
48 | $array = array('green', 'yellow', 'blue', 'pink', 'orange'); |
||
49 | $form = new Form( |
||
50 | $this, |
||
51 | 'TestForm', |
||
52 | $fields = FieldList::create( |
||
53 | HeaderField::create('HeaderField1', 'HeaderField Level 1', 1), |
||
54 | LiteralField::create('LiteralField', '<p>All fields up to EmailField are required and should be marked as such</p>'), |
||
55 | TextField::create('TextField1', 'Text Field Example 1'), |
||
56 | TextField::create('TextField2', 'Text Field Example 2'), |
||
57 | TextField::create('TextField3', 'Text Field Example 3'), |
||
58 | TextField::create('TextField4', ''), |
||
59 | HeaderField::create('FieldGroupHdr', 'First/last name FieldGroup'), |
||
60 | FieldGroup::create( |
||
61 | TextField::create('FirstName1', 'First Name'), |
||
62 | TextField::create('LastName1', 'Last Name') |
||
63 | ), |
||
64 | HeaderField::create('HeaderField2b', 'Field with right title', 2), |
||
65 | TextareaField::create('TextareaField', 'Textarea Field') |
||
66 | ->setColumns(45) |
||
67 | ->setRightTitle('This is the right title'), |
||
68 | EmailField::create('EmailField', 'Email address'), |
||
69 | HeaderField::create('HeaderField2c', 'HeaderField Level 2', 2), |
||
70 | DropdownField::create('DropdownField', 'Dropdown Field', array(0 => '-- please select --', 1 => 'test AAAA', 2 => 'test BBBB')), |
||
71 | OptionsetField::create('OptionSF', 'Optionset Field', $array), |
||
72 | CheckboxSetField::create('CheckboxSF', 'Checkbox Set Field', $array), |
||
73 | CurrencyField::create('CurrencyField', 'Bling bling', '$123.45'), |
||
74 | HeaderField::create('HeaderField3', 'Other Fields', 3), |
||
75 | NumericField::create('NumericField', 'Numeric Field '), |
||
76 | DateField::create('DateField', 'Date Field'), |
||
77 | DateTimeField::create('DateTimeField', 'Date and Time Field'), |
||
78 | CheckboxField::create('CheckboxField', 'Checkbox Field') |
||
79 | ), |
||
80 | $actions = FieldList::create( |
||
81 | FormAction::create('submit', 'Submit Button') |
||
82 | ), |
||
83 | $requiredFields = RequiredFields::create( |
||
84 | 'TextField1', |
||
85 | 'TextField2', |
||
86 | 'TextField3', |
||
87 | 'ErrorField1', |
||
88 | 'ErrorField2', |
||
89 | 'EmailField', |
||
90 | 'TextField3', |
||
91 | 'RightTitleField', |
||
92 | 'CheckboxField', |
||
93 | 'CheckboxSetField' |
||
94 | ) |
||
95 | ); |
||
96 | $form->setMessage('warning message', 'warning'); |
||
97 | return $form; |
||
98 | } |
||
104 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.