Conditions | 1 |
Paths | 1 |
Total Lines | 53 |
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 |
||
95 | private static function createContext( $site ) |
||
96 | { |
||
97 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
||
98 | $aimeos = self::getAimeos(); |
||
99 | |||
100 | |||
101 | $paths = $aimeos->getConfigPaths(); |
||
102 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
||
103 | $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; |
||
104 | $local = array( 'resource' => array( 'fs' => array( 'adapter' => 'Standard', 'basedir' => __DIR__ . '/tmp' ) ) ); |
||
105 | |||
106 | $conf = new \Aimeos\MW\Config\PHPArray( $local, $paths ); |
||
107 | $conf = new \Aimeos\MW\Config\Decorator\Memory( $conf ); |
||
108 | $conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file ); |
||
109 | $ctx->setConfig( $conf ); |
||
110 | |||
111 | |||
112 | $logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
||
113 | $ctx->setLogger( $logger ); |
||
114 | |||
115 | |||
116 | $dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
||
117 | $ctx->setDatabaseManager( $dbm ); |
||
118 | |||
119 | |||
120 | $fs = new \Aimeos\MW\Filesystem\Manager\Standard( $conf ); |
||
121 | $ctx->setFilesystemManager( $fs ); |
||
122 | |||
123 | |||
124 | $mq = new \Aimeos\MW\MQueue\Manager\Standard( $conf ); |
||
125 | $ctx->setMessageQueueManager( $mq ); |
||
126 | |||
127 | |||
128 | $cache = new \Aimeos\MW\Cache\None(); |
||
129 | $ctx->setCache( $cache ); |
||
130 | |||
131 | |||
132 | $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
||
133 | $ctx->setI18n( array( 'de' => $i18n ) ); |
||
134 | |||
135 | |||
136 | $session = new \Aimeos\MW\Session\None(); |
||
137 | $ctx->setSession( $session ); |
||
138 | |||
139 | |||
140 | $localeManager = \Aimeos\MShop\Locale\Manager\Factory::create( $ctx ); |
||
141 | $locale = $localeManager->bootstrap( $site, '', '', false ); |
||
142 | $ctx->setLocale( $locale ); |
||
143 | |||
144 | |||
145 | $ctx->setEditor( 'ai-client-html:client/html' ); |
||
146 | |||
147 | return $ctx; |
||
148 | } |
||
150 |