| Conditions | 10 |
| Paths | 8 |
| Total Lines | 34 |
| Code Lines | 29 |
| 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 |
||
| 25 | public function __construct($request, $relativeCmsUri, $cmsComponent) |
||
| 26 | { |
||
| 27 | if ($relativeCmsUri == '/configuration/bricks') { |
||
| 28 | $cmsComponent->subTemplate = 'cms/configuration/bricks'; |
||
| 29 | $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_CONFIGURATION); |
||
| 30 | $cmsComponent->setParameter(CmsComponent::PARAMETER_BRICKS, $cmsComponent->storage->getBricks()); |
||
| 31 | } elseif ($relativeCmsUri == '/configuration/bricks/new') { |
||
| 32 | $cmsComponent->subTemplate = 'cms/configuration/bricks-form'; |
||
| 33 | $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_CONFIGURATION); |
||
| 34 | if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE])) { |
||
| 35 | $cmsComponent->storage->addBrick($request::$post); |
||
| 36 | header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/configuration/bricks'); |
||
| 37 | exit; |
||
| 38 | } |
||
| 39 | } elseif ($relativeCmsUri == '/configuration/bricks/edit' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
||
| 40 | $cmsComponent->subTemplate = 'cms/configuration/bricks-form'; |
||
| 41 | $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_CONFIGURATION); |
||
| 42 | $brick = $cmsComponent->storage->getBrickBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
||
| 43 | if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE])) { |
||
| 44 | $cmsComponent->storage->saveBrick($request::$get[CmsComponent::GET_PARAMETER_SLUG], $request::$post); |
||
| 45 | header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/configuration/bricks'); |
||
| 46 | exit; |
||
| 47 | } |
||
| 48 | $cmsComponent->setParameter(CmsComponent::PARAMETER_BRICK, $brick); |
||
| 49 | } elseif ($relativeCmsUri == '/configuration/bricks/delete' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
||
| 50 | $cmsComponent->storage->deleteBrickBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
||
| 51 | header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/configuration/bricks'); |
||
| 52 | exit; |
||
| 53 | } elseif ($relativeCmsUri == '/configuration/image-set') { |
||
| 54 | $cmsComponent->subTemplate = 'cms/configuration/image-set'; |
||
| 55 | $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_CONFIGURATION); |
||
| 56 | $cmsComponent->setParameter(CmsComponent::PARAMETER_IMAGE_SET, $cmsComponent->storage->getImageSet()); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | } |