| Conditions | 1 |
| Paths | 1 |
| Total Lines | 60 |
| Code Lines | 32 |
| 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 |
||
| 66 | private static function createContext( $site ) |
||
| 67 | { |
||
| 68 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
||
| 69 | $aimeos = self::getAimeos(); |
||
| 70 | |||
| 71 | |||
| 72 | $paths = $aimeos->getConfigPaths(); |
||
| 73 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
||
| 74 | $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; |
||
| 75 | |||
| 76 | $conf = new \Aimeos\MW\Config\PHPArray( [], $paths ); |
||
| 77 | $conf = new \Aimeos\MW\Config\Decorator\Memory( $conf ); |
||
| 78 | $conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file ); |
||
| 79 | $ctx->setConfig( $conf ); |
||
| 80 | |||
| 81 | |||
| 82 | $logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
||
| 83 | $ctx->setLogger( $logger ); |
||
| 84 | |||
| 85 | |||
| 86 | $dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
||
| 87 | $ctx->setDatabaseManager( $dbm ); |
||
| 88 | |||
| 89 | |||
| 90 | $fs = new \Aimeos\MW\Filesystem\Manager\Standard( $conf ); |
||
| 91 | $ctx->setFilesystemManager( $fs ); |
||
| 92 | |||
| 93 | |||
| 94 | $mq = new \Aimeos\MW\MQueue\Manager\Standard( $conf ); |
||
| 95 | $ctx->setMessageQueueManager( $mq ); |
||
| 96 | |||
| 97 | |||
| 98 | $cache = new \Aimeos\MW\Cache\None(); |
||
| 99 | $ctx->setCache( $cache ); |
||
| 100 | |||
| 101 | |||
| 102 | $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
||
| 103 | $ctx->setI18n( array( 'de' => $i18n ) ); |
||
| 104 | |||
| 105 | |||
| 106 | $session = new \Aimeos\MW\Session\None(); |
||
| 107 | $ctx->setSession( $session ); |
||
| 108 | |||
| 109 | |||
| 110 | $mail = new \Aimeos\MW\Mail\None(); |
||
| 111 | $ctx->setMail( $mail ); |
||
| 112 | |||
| 113 | |||
| 114 | $view = self::createView( $conf ); |
||
| 115 | $ctx->setView( $view ); |
||
| 116 | |||
| 117 | |||
| 118 | $localeManager = \Aimeos\MShop\Locale\Manager\Factory::create( $ctx ); |
||
| 119 | $locale = $localeManager->bootstrap( $site, 'de', '', false ); |
||
| 120 | $ctx->setLocale( $locale ); |
||
| 121 | |||
| 122 | |||
| 123 | $ctx->setEditor( 'core:lib/mshoplib' ); |
||
| 124 | |||
| 125 | return $ctx; |
||
| 126 | } |
||
| 164 |