Conditions | 1 |
Paths | 1 |
Total Lines | 54 |
Code Lines | 38 |
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 |
||
137 | public function getCMSFields() |
||
138 | { |
||
139 | $fields = parent::getCMSFields(); |
||
140 | $fields->removeFieldsFromTab( |
||
141 | 'Root.Main', |
||
142 | [ |
||
143 | 'FieldsSent', |
||
144 | 'Filters', |
||
145 | 'HasError', |
||
146 | 'Executed', |
||
147 | ] |
||
148 | ); |
||
149 | $fields->addFieldsToTab( |
||
150 | 'Root.Main', |
||
151 | [ |
||
152 | ReadonlyField::create( |
||
153 | 'Created', |
||
154 | 'Created', |
||
155 | DBField::create_field('SS_DateTime', $this->Created)->Nice() |
||
156 | ), |
||
157 | ReadonlyField::create( |
||
158 | 'SalesforceIdentifier', |
||
159 | 'Sales Force Identifier' |
||
160 | ), |
||
161 | LiteralField::create( |
||
162 | 'FieldsSentNice', |
||
163 | '<h2>Fields Sent</h2>'.$this->serializedToHTML($this->FieldsSent) |
||
1 ignored issue
–
show
|
|||
164 | ), |
||
165 | ReadonlyField::create( |
||
166 | 'Type', |
||
167 | 'Type' |
||
168 | ), |
||
169 | LiteralField::create( |
||
170 | 'FiltersNice', |
||
171 | '<h2>Filters</h2>'.$this->serializedToHTML($this->Filters) |
||
1 ignored issue
–
show
|
|||
172 | ), |
||
173 | ReadonlyField::create( |
||
174 | 'ExecutedNice', |
||
175 | 'Executed', |
||
176 | DBField::create_field('Boolean', $this->Executed)->Nice() |
||
1 ignored issue
–
show
|
|||
177 | ), |
||
178 | ReadonlyField::create( |
||
179 | 'HasErrorNice', |
||
180 | 'HasError', |
||
181 | DBField::create_field('Boolean', $this->HasError)->Nice() |
||
182 | ), |
||
183 | ReadonlyField::create( |
||
184 | 'Errors', |
||
185 | 'Communication Errors' |
||
186 | )->setRightTitle('Separated by three ||| symbols.') |
||
187 | ] |
||
188 | ); |
||
189 | |||
190 | return $fields; |
||
191 | } |
||
236 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.