Conditions | 2 |
Paths | 2 |
Total Lines | 52 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 7 | ||
Bugs | 1 | 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 |
||
35 | public function create( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $locale = null ) |
||
36 | { |
||
37 | $params = $fixed = array(); |
||
38 | |||
39 | if( $locale !== null ) |
||
40 | { |
||
41 | $params = Route::current()->parameters() + Input::all(); |
||
42 | $fixed = $this->getFixedParams(); |
||
43 | |||
44 | $i18n = app('\Aimeos\Shop\Base\I18n')->get( array( $locale ) ); |
||
45 | $translation = $i18n[$locale]; |
||
46 | } |
||
47 | else |
||
48 | { |
||
49 | $translation = new \Aimeos\MW\Translation\None( 'en' ); |
||
50 | } |
||
51 | |||
52 | |||
53 | $view = new \Aimeos\MW\View\Standard( $templatePaths ); |
||
54 | |||
55 | $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $translation ); |
||
56 | $view->addHelper( 'translate', $helper ); |
||
57 | |||
58 | $helper = new \Aimeos\MW\View\Helper\Url\Laravel5( $view, app('url'), $fixed ); |
||
59 | $view->addHelper( 'url', $helper ); |
||
60 | |||
61 | $helper = new \Aimeos\MW\View\Helper\Param\Standard( $view, $params ); |
||
62 | $view->addHelper( 'param', $helper ); |
||
63 | |||
64 | $config = new \Aimeos\MW\Config\Decorator\Protect( clone $context->getConfig(), array( 'admin', 'client' ) ); |
||
65 | $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
||
66 | $view->addHelper( 'config', $helper ); |
||
67 | |||
68 | $sepDec = $config->get( 'client/html/common/format/seperatorDecimal', '.' ); |
||
69 | $sep1000 = $config->get( 'client/html/common/format/seperator1000', ' ' ); |
||
70 | $helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, $sepDec, $sep1000 ); |
||
71 | $view->addHelper( 'number', $helper ); |
||
72 | |||
73 | $helper = new \Aimeos\MW\View\Helper\Request\Laravel5( $view, Request::instance() ); |
||
|
|||
74 | $view->addHelper( 'request', $helper ); |
||
75 | |||
76 | $helper = new \Aimeos\MW\View\Helper\Response\Laravel5( $view ); |
||
77 | $view->addHelper( 'response', $helper ); |
||
78 | |||
79 | $helper = new \Aimeos\MW\View\Helper\Csrf\Standard( $view, '_token', csrf_token() ); |
||
80 | $view->addHelper( 'csrf', $helper ); |
||
81 | |||
82 | $helper = new \Aimeos\MW\View\Helper\Access\Standard( $view, $this->getGroups( $context ) ); |
||
83 | $view->addHelper( 'access', $helper ); |
||
84 | |||
85 | return $view; |
||
86 | } |
||
87 | |||
137 | } |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.