| Conditions | 2 |
| Paths | 2 |
| Total Lines | 55 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 101 | public static function view( $site = 'unittest', ?\Aimeos\Base\Config\Iface $config = null ) |
||
| 102 | { |
||
| 103 | $aimeos = self::getAimeos(); |
||
| 104 | |||
| 105 | if( $config === null ) { |
||
| 106 | $config = self::context( $site )->config(); |
||
| 107 | } |
||
| 108 | |||
| 109 | $templates = array_merge_recursive( |
||
| 110 | $aimeos->getTemplatePaths( 'admin/jqadm/templates' ), |
||
| 111 | $aimeos->getTemplatePaths( 'client/html/templates' ), |
||
| 112 | $aimeos->getTemplatePaths( 'client/jsonapi/templates' ) |
||
| 113 | ); |
||
| 114 | |||
| 115 | $view = new \Aimeos\Base\View\Standard( $templates ); |
||
| 116 | |||
| 117 | $helper = new \Aimeos\Base\View\Helper\Param\Standard( $view, ['site' => 'unittest'] ); |
||
| 118 | $view->addHelper( 'param', $helper ); |
||
| 119 | |||
| 120 | $helper = new \Aimeos\Base\View\Helper\Access\All( $view ); |
||
| 121 | $view->addHelper( 'access', $helper ); |
||
| 122 | |||
| 123 | $trans = new \Aimeos\Base\Translation\None( 'de_DE' ); |
||
| 124 | $helper = new \Aimeos\Base\View\Helper\Translate\Standard( $view, $trans ); |
||
| 125 | $view->addHelper( 'translate', $helper ); |
||
| 126 | |||
| 127 | $helper = new \Aimeos\Base\View\Helper\Url\Standard( $view, 'http://baseurl' ); |
||
| 128 | $view->addHelper( 'url', $helper ); |
||
| 129 | |||
| 130 | $helper = new \Aimeos\Base\View\Helper\Number\Standard( $view, '.', '' ); |
||
| 131 | $view->addHelper( 'number', $helper ); |
||
| 132 | |||
| 133 | $helper = new \Aimeos\Base\View\Helper\Date\Standard( $view, 'Y-m-d' ); |
||
| 134 | $view->addHelper( 'date', $helper ); |
||
| 135 | |||
| 136 | $config = new \Aimeos\Base\Config\Decorator\Protect( $config, ['version', 'admin', 'client', 'resource/fs/baseurl', 'resource/fs-media/baseurl', 'resource/fs-theme/baseurl'] ); |
||
| 137 | $helper = new \Aimeos\Base\View\Helper\Config\Standard( $view, $config ); |
||
| 138 | $view->addHelper( 'config', $helper ); |
||
| 139 | |||
| 140 | $helper = new \Aimeos\Base\View\Helper\Session\Standard( $view, new \Aimeos\Base\Session\None() ); |
||
| 141 | $view->addHelper( 'session', $helper ); |
||
| 142 | |||
| 143 | $psr17Factory = new \Nyholm\Psr7\Factory\Psr17Factory(); |
||
| 144 | $helper = new \Aimeos\Base\View\Helper\Request\Standard( $view, $psr17Factory->createServerRequest( 'GET', 'https://aimeos.org' ) ); |
||
| 145 | $view->addHelper( 'request', $helper ); |
||
| 146 | |||
| 147 | $helper = new \Aimeos\Base\View\Helper\Response\Standard( $view, $psr17Factory->createResponse() ); |
||
| 148 | $view->addHelper( 'response', $helper ); |
||
| 149 | |||
| 150 | $helper = new \Aimeos\Base\View\Helper\Csrf\Standard( $view, '_csrf_token', '_csrf_value' ); |
||
| 151 | $view->addHelper( 'csrf', $helper ); |
||
| 152 | |||
| 153 | $view->pageSitePath = []; |
||
| 154 | |||
| 155 | return $view; |
||
| 156 | } |
||
| 157 | } |