| Conditions | 1 |
| Paths | 1 |
| Total Lines | 157 |
| Code Lines | 107 |
| 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 |
||
| 210 | protected function addLogosAndIcons(FieldList $fields) |
||
| 211 | { |
||
| 212 | $logoTypes = array('jpg', 'jpeg', 'png', 'gif'); |
||
| 213 | $iconTypes = array('ico'); |
||
| 214 | $appleTouchTypes = array('png'); |
||
| 215 | |||
| 216 | $fields->findOrMakeTab( |
||
| 217 | 'Root.LogosIcons', |
||
| 218 | _t(__CLASS__ . '.LogosIconsTab', 'Logos/Icons') |
||
| 219 | ); |
||
| 220 | |||
| 221 | $fields->addFieldToTab( |
||
| 222 | 'Root.LogosIcons', |
||
| 223 | $logoField = Injector::inst()->create( |
||
| 224 | FileHandleField::class, |
||
| 225 | 'Logo', |
||
| 226 | _t(__CLASS__ . '.LogoUploadField', 'Logo, to appear in the top left') |
||
| 227 | ) |
||
| 228 | ); |
||
| 229 | $logoField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 230 | |||
| 231 | $fields->addFieldToTab( |
||
| 232 | 'Root.LogosIcons', |
||
| 233 | $logoRetinaField = Injector::inst()->create( |
||
| 234 | FileHandleField::class, |
||
| 235 | 'LogoRetina', |
||
| 236 | _t( |
||
| 237 | 'CwpConfig.LogoRetinaUploadField', |
||
| 238 | 'High resolution logo, to appear in the top left ' . |
||
| 239 | '(recommended to be twice the height and width of the standard logo)' |
||
| 240 | ) |
||
| 241 | ) |
||
| 242 | ); |
||
| 243 | $logoRetinaField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 244 | |||
| 245 | $fields->addFieldToTab( |
||
| 246 | 'Root.LogosIcons', |
||
| 247 | $footerLogoField = Injector::inst()->create( |
||
| 248 | FileHandleField::class, |
||
| 249 | 'FooterLogo', |
||
| 250 | _t(__CLASS__ . '.FooterLogoField', 'Footer logo, to appear in the footer') |
||
| 251 | ) |
||
| 252 | ); |
||
| 253 | $footerLogoField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 254 | |||
| 255 | $fields->addFieldToTab( |
||
| 256 | 'Root.LogosIcons', |
||
| 257 | $footerLogoRetinaField = Injector::inst()->create( |
||
| 258 | FileHandleField::class, |
||
| 259 | 'FooterLogoRetina', |
||
| 260 | _t( |
||
| 261 | 'CwpConfig.FooterLogoRetinaField', |
||
| 262 | 'High resolution footer logo (recommended twice the height and width of the standard footer logo)' |
||
| 263 | ) |
||
| 264 | ) |
||
| 265 | ); |
||
| 266 | $footerLogoRetinaField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 267 | |||
| 268 | $fields->addFieldToTab( |
||
| 269 | 'Root.LogosIcons', |
||
| 270 | $footerLink = TextField::create( |
||
| 271 | 'FooterLogoLink', |
||
| 272 | _t(__CLASS__ . '.FooterLogoLinkField', 'Footer Logo link') |
||
| 273 | ) |
||
| 274 | ); |
||
| 275 | $footerLink->setRightTitle( |
||
| 276 | _t( |
||
| 277 | 'CwpConfig.FooterLogoLinkDesc', |
||
| 278 | 'Please include the protocol (ie, http:// or https://) unless it is an internal link.' |
||
| 279 | ) |
||
| 280 | ); |
||
| 281 | |||
| 282 | $fields->addFieldToTab( |
||
| 283 | 'Root.LogosIcons', |
||
| 284 | TextField::create( |
||
| 285 | 'FooterLogoDescription', |
||
| 286 | _t(__CLASS__ . '.FooterLogoDescField', 'Footer Logo description') |
||
| 287 | ) |
||
| 288 | ); |
||
| 289 | |||
| 290 | $fields->addFieldToTab( |
||
| 291 | 'Root.LogosIcons', |
||
| 292 | $footerLogoSecondaryField = Injector::inst()->create( |
||
| 293 | FileHandleField::class, |
||
| 294 | 'FooterLogoSecondary', |
||
| 295 | _t(__CLASS__ . '.FooterLogoSecondaryField', 'Secondary Footer Logo, to appear in the footer.') |
||
| 296 | ) |
||
| 297 | ); |
||
| 298 | $footerLogoSecondaryField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 299 | |||
| 300 | $fields->addFieldToTab('Root.LogosIcons', $footerSecondaryLink = TextField::create( |
||
| 301 | 'FooterLogoSecondaryLink', |
||
| 302 | _t(__CLASS__ . '.FooterLogoSecondaryLinkField', 'Secondary Footer Logo link.') |
||
| 303 | )); |
||
| 304 | $footerSecondaryLink->setRightTitle(_t( |
||
| 305 | 'CwpConfig.FooterLogoSecondaryLinkDesc', |
||
| 306 | 'Please include the protocol (ie, http:// or https://) unless it is an internal link.' |
||
| 307 | )); |
||
| 308 | $fields->addFieldToTab('Root.LogosIcons', TextField::create( |
||
| 309 | 'FooterLogoSecondaryDescription', |
||
| 310 | _t(__CLASS__ . '.FooterLogoSecondaryDescField', 'Secondary Footer Logo description') |
||
| 311 | )); |
||
| 312 | |||
| 313 | $fields->addFieldToTab( |
||
| 314 | 'Root.LogosIcons', |
||
| 315 | $favIconField = Injector::inst()->create( |
||
| 316 | FileHandleField::class, |
||
| 317 | 'FavIcon', |
||
| 318 | _t(__CLASS__ . '.FavIconField', 'Favicon, in .ico format, dimensions of 16x16, 32x32, or 48x48') |
||
| 319 | ) |
||
| 320 | ); |
||
| 321 | $favIconField->getValidator()->setAllowedExtensions($iconTypes); |
||
| 322 | |||
| 323 | $fields->addFieldToTab( |
||
| 324 | 'Root.LogosIcons', |
||
| 325 | $atIcon144 = Injector::inst()->create( |
||
| 326 | FileHandleField::class, |
||
| 327 | 'AppleTouchIcon144', |
||
| 328 | _t( |
||
| 329 | 'CwpConfig.AppleIconField144', |
||
| 330 | 'Apple Touch Web Clip and Windows 8 Tile Icon (dimensions of 144x144, PNG format)' |
||
| 331 | ) |
||
| 332 | ) |
||
| 333 | ); |
||
| 334 | $atIcon144->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 335 | |||
| 336 | $fields->addFieldToTab( |
||
| 337 | 'Root.LogosIcons', |
||
| 338 | $atIcon114 = Injector::inst()->create( |
||
| 339 | FileHandleField::class, |
||
| 340 | 'AppleTouchIcon114', |
||
| 341 | _t(__CLASS__ . '.AppleIconField114', 'Apple Touch Web Clip Icon (dimensions of 114x114, PNG format)') |
||
| 342 | ) |
||
| 343 | ); |
||
| 344 | $atIcon114->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 345 | |||
| 346 | $fields->addFieldToTab( |
||
| 347 | 'Root.LogosIcons', |
||
| 348 | $atIcon72 = Injector::inst()->create( |
||
| 349 | FileHandleField::class, |
||
| 350 | 'AppleTouchIcon72', |
||
| 351 | _t(__CLASS__ . '.AppleIconField72', 'Apple Touch Web Clip Icon (dimensions of 72x72, PNG format)') |
||
| 352 | ) |
||
| 353 | ); |
||
| 354 | $atIcon72->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 355 | |||
| 356 | $fields->addFieldToTab( |
||
| 357 | 'Root.LogosIcons', |
||
| 358 | $atIcon57 = Injector::inst()->create( |
||
| 359 | FileHandleField::class, |
||
| 360 | 'AppleTouchIcon57', |
||
| 361 | _t(__CLASS__ . '.AppleIconField57', 'Apple Touch Web Clip Icon (dimensions of 57x57, PNG format)') |
||
| 362 | ) |
||
| 363 | ); |
||
| 364 | $atIcon57->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 365 | |||
| 366 | return $this; |
||
| 367 | } |
||
| 579 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths