| Conditions | 1 |
| Paths | 1 |
| Total Lines | 84 |
| Code Lines | 66 |
| 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 |
||
| 192 | private function createArticleFieldDefinitions() |
||
| 193 | { |
||
| 194 | /** @var $fieldType \eZ\Publish\SPI\FieldType\FieldType */ |
||
| 195 | $fieldDefinitions[] = new FieldDefinition( |
||
| 196 | array( |
||
| 197 | "names" => 'Title', |
||
| 198 | "descriptions" => '', |
||
| 199 | "id" => 1, |
||
| 200 | "identifier" => 'title', |
||
| 201 | "fieldGroup" => 'default', |
||
| 202 | "position" => 10, |
||
| 203 | "fieldTypeIdentifier" => 'ezstring', |
||
| 204 | "isTranslatable" => false, |
||
| 205 | "isRequired" => true, |
||
| 206 | "isInfoCollector" => false, |
||
| 207 | "defaultValue" => '', |
||
| 208 | "isSearchable" => true, |
||
| 209 | "fieldSettings" => array(), |
||
| 210 | "validatorConfiguration" => array(), |
||
| 211 | ) |
||
| 212 | ); |
||
| 213 | |||
| 214 | /** @var $fieldType \eZ\Publish\SPI\FieldType\FieldType */ |
||
| 215 | $fieldDefinitions[] = new FieldDefinition( |
||
| 216 | array( |
||
| 217 | "names" => 'Author', |
||
| 218 | "descriptions" => '', |
||
| 219 | "id" => 2, |
||
| 220 | "identifier" => 'author', |
||
| 221 | "fieldGroup" => 'default', |
||
| 222 | "position" => 20, |
||
| 223 | "fieldTypeIdentifier" => 'ezstring', |
||
| 224 | "isTranslatable" => false, |
||
| 225 | "isRequired" => true, |
||
| 226 | "isInfoCollector" => false, |
||
| 227 | "defaultValue" => '', |
||
| 228 | "isSearchable" => true, |
||
| 229 | "fieldSettings" => array(), |
||
| 230 | "validatorConfiguration" => array(), |
||
| 231 | ) |
||
| 232 | ); |
||
| 233 | |||
| 234 | /** @var $fieldType \eZ\Publish\SPI\FieldType\FieldType */ |
||
| 235 | $fieldDefinitions[] = new FieldDefinition( |
||
| 236 | array( |
||
| 237 | "names" => 'Teaser', |
||
| 238 | "descriptions" => '', |
||
| 239 | "id" => 3, |
||
| 240 | "identifier" => 'intro', |
||
| 241 | "fieldGroup" => 'default', |
||
| 242 | "position" => 30, |
||
| 243 | "fieldTypeIdentifier" => 'ezxmltext', |
||
| 244 | "isTranslatable" => false, |
||
| 245 | "isRequired" => true, |
||
| 246 | "isInfoCollector" => false, |
||
| 247 | "defaultValue" => '', |
||
| 248 | "isSearchable" => true, |
||
| 249 | "fieldSettings" => array(), |
||
| 250 | "validatorConfiguration" => array(), |
||
| 251 | ) |
||
| 252 | ); |
||
| 253 | |||
| 254 | /** @var $fieldType \eZ\Publish\SPI\FieldType\FieldType */ |
||
| 255 | $fieldDefinitions[] = new FieldDefinition( |
||
| 256 | array( |
||
| 257 | "names" => 'Body', |
||
| 258 | "descriptions" => '', |
||
| 259 | "id" => 4, |
||
| 260 | "identifier" => 'body', |
||
| 261 | "fieldGroup" => 'default', |
||
| 262 | "position" => 40, |
||
| 263 | "fieldTypeIdentifier" => 'ezxmltext', |
||
| 264 | "isTranslatable" => false, |
||
| 265 | "isRequired" => true, |
||
| 266 | "isInfoCollector" => false, |
||
| 267 | "defaultValue" => '', |
||
| 268 | "isSearchable" => true, |
||
| 269 | "fieldSettings" => array(), |
||
| 270 | "validatorConfiguration" => array(), |
||
| 271 | ) |
||
| 272 | ); |
||
| 273 | |||
| 274 | return $fieldDefinitions; |
||
| 275 | } |
||
| 276 | |||
| 301 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.