| Conditions | 2 |
| Paths | 2 |
| Total Lines | 54 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 2 |
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 |
||
| 49 | public function create( ServerRequestInterface $request, ResponseInterface $response, array $attr, array $templatePaths, $locale = null ) |
||
| 50 | { |
||
| 51 | $params = $fixed = array(); |
||
| 52 | $config = $this->container->get( 'aimeos_config' ); |
||
| 53 | |||
| 54 | if( $locale !== null ) |
||
| 55 | { |
||
| 56 | $params = $attr + (array) $request->getParsedBody() + (array) $request->getQueryParams(); |
||
| 57 | $fixed = $this->getFixedParams( $attr ); |
||
| 58 | |||
| 59 | $i18n = $this->container->get( 'aimeos_i18n' )->get( array( $locale ) ); |
||
| 60 | $translation = $i18n[$locale]; |
||
| 61 | } |
||
| 62 | else |
||
| 63 | { |
||
| 64 | $translation = new \Aimeos\MW\Translation\None( 'en' ); |
||
| 65 | } |
||
| 66 | |||
| 67 | |||
| 68 | $view = new \Aimeos\MW\View\Standard( $templatePaths ); |
||
| 69 | |||
| 70 | $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $translation ); |
||
| 71 | $view->addHelper( 'translate', $helper ); |
||
| 72 | |||
| 73 | $helper = new \Aimeos\MW\View\Helper\Url\Slim( $view, $this->container->get( 'router' ), $fixed ); |
||
| 74 | $view->addHelper( 'url', $helper ); |
||
| 75 | |||
| 76 | $helper = new \Aimeos\MW\View\Helper\Param\Standard( $view, $params ); |
||
| 77 | $view->addHelper( 'param', $helper ); |
||
| 78 | |||
| 79 | $config = new \Aimeos\MW\Config\Decorator\Protect( clone $config, array( 'admin', 'client' ) ); |
||
| 80 | $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
||
| 81 | $view->addHelper( 'config', $helper ); |
||
| 82 | |||
| 83 | $sepDec = $config->get( 'client/html/common/format/seperatorDecimal', '.' ); |
||
| 84 | $sep1000 = $config->get( 'client/html/common/format/seperator1000', ' ' ); |
||
| 85 | $helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, $sepDec, $sep1000 ); |
||
| 86 | $view->addHelper( 'number', $helper ); |
||
| 87 | |||
| 88 | $helper = new \Aimeos\MW\View\Helper\Request\Slim( $view, $request ); |
||
| 89 | $view->addHelper( 'request', $helper ); |
||
| 90 | |||
| 91 | $helper = new \Aimeos\MW\View\Helper\Response\Slim( $view, $response ); |
||
| 92 | $view->addHelper( 'response', $helper ); |
||
| 93 | |||
| 94 | $csrf = $request->getAttribute( 'csrf_name' ); |
||
| 95 | $helper = new \Aimeos\MW\View\Helper\Csrf\Standard( $view, $csrf, $request->getAttribute( 'csrf_value ') ); |
||
| 96 | $view->addHelper( 'csrf', $helper ); |
||
| 97 | |||
| 98 | $helper = new \Aimeos\MW\View\Helper\Access\Standard( $view, $this->getGroups( $context ) ); |
||
|
|
|||
| 99 | $view->addHelper( 'access', $helper ); |
||
| 100 | |||
| 101 | return $view; |
||
| 102 | } |
||
| 103 | |||
| 155 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.