Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
Code Lines | 48 |
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 |
||
52 | public function Form() |
||
53 | { |
||
54 | $form = KnockoutForm::create( |
||
55 | $this, |
||
56 | 'Form', |
||
57 | FieldList::create( |
||
58 | KnockoutTextField::create('Spaceship', 'Spaceship') |
||
59 | ->setObservable('spaceship2') |
||
60 | ->setHasFocus(true), |
||
61 | KnockoutTextField::create('FieldWithComma', 'FieldWithComma') |
||
62 | ->setObservable('fieldwithcomma') |
||
63 | ->setValue("Enterprise's Voyage"), |
||
64 | KnockoutDropdownField::create( |
||
65 | 'Menu', |
||
66 | 'Space Menu', |
||
67 | array('1'=>'Light Speed Salad','2'=>'Comet Custard') |
||
68 | )->setObservable('menu'), |
||
69 | KnockoutNumericField::create('SeatNumber', 'Seat Number', 4) |
||
70 | ->setObservable('seatNumber'), |
||
71 | KnockoutEmailField::create('Email', 'Email') |
||
72 | ->setObservable('email') |
||
73 | ->setValue('[email protected]'), |
||
74 | KnockoutTextareaField::create('Comments', 'Comments') |
||
75 | ->setObservable('comments'), |
||
76 | KnockoutOptionsetField::create( |
||
77 | 'Accessories', |
||
78 | 'Accessories', |
||
79 | array( |
||
80 | 'Flying High DVD' => 'Flying High DVD', |
||
81 | 'Zero Gravity Pillow' => 'Zero Gravity Pillow', |
||
82 | 'Rocket Replica' => 'Rocket Replica' |
||
83 | ), |
||
84 | 'Zero Gravity Pillow' |
||
85 | )->setObservable('accessories') |
||
86 | ->setOtherBindings("blah: someOtherFunction"), |
||
87 | KnockoutConfirmedPasswordField::create('Password', 'Password'), |
||
88 | KnockoutCheckboxField::create('CheckboxFieldExample', 'Checkbox Field Example') |
||
89 | ->setObservable('checkboxField'), |
||
90 | KnockoutSwitchField::create('SwitchFieldExample', 'Switch Field Example') |
||
91 | ->setObservable('switchField'), |
||
92 | KnockoutToggleCompositeButtonField::create( |
||
93 | "MyToggleCompositeButtonField", |
||
94 | "This is a knockout composite button field", |
||
95 | [ |
||
96 | KnockoutTextField::create('Test1', 'Test1')->setObservable('test1'), |
||
97 | KnockoutTextField::create('Test2', 'Test2')->setObservable('test2') |
||
98 | ] |
||
99 | )->setObservable('compositeButtonField') |
||
100 | // add any new knockout fields here and assert above |
||
101 | ), |
||
102 | FieldList::create( |
||
103 | KnockoutFormAction::create('doSubmit', 'Submit') |
||
104 | ->setObservable('canSaveInterGalacticAction') |
||
105 | ) |
||
106 | ); |
||
107 | $form->setSubmit('addToCart2'); |
||
108 | |||
109 | return $form; |
||
110 | } |
||
123 |